我通过创建一个配置类在我的应用程序中实现oauth2安全性,但我不知道我在哪里犯了错误,我得到了以下类型的编译时错误
Type arguments should be specified for an outer class 'ExpressionUrlAuthorizationConfigurer'. Use full class name to specify them
securityconfig.kt
package com.main.serviceproduct.config
import org.springframework.context.annotation.Configuration
import org.springframework.security.config.Customizer
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer
@Configuration
@EnableWebSecurity
class SecurityConfig : WebSecurityConfigurerAdapter() {
@Throws(Exception::class)
override fun configure(security: HttpSecurity){
security.authorizeRequests(Customizer { authorize: ExpressionInterceptUrlRegistry ->
authorize.anyRequest().authenticated()
})
.oauth2ResourceServer{obj: OAuth2ResourceServerConfigurer<HttpSecurity?>->obj.jwt()}
}
}
security.authorizeRequests(Customizer { authorize: ExpressionInterceptUrlRegistry ->
authorize.anyRequest().authenticated()
在这一点上,我在上面的一行上得到了错误授权:expressionIntercepturRegistry
1条答案
按热度按时间a11xaf1n1#
因为
ExpressionInterceptUrlRegistry
是一个内部(非静态)类,因此它需要外部类的类型信息ExpressionUrlAuthorizationConfigurer<T>
,这实际上是一个HttpSecurity
.以下方法应该有效: