我不能在我的AuthenticationProvider类中自动创建一个SecurityConfig Spring框架实例。这很奇怪,因为我已经包含了必要的导入,并且UserDetailsService (另一个Spring类)可以自动处理,不会出现任何问题。这是我的密码:
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.security.authentication.AuthenticationProvider
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity
import org.springframework.security.config.annotation.web.builders.HttpSecurity
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
import org.springframework.security.core.userdetails.UserDetailsService
import org.springframework.security.web.authentication.RememberMeServices
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices
@Configuration
@EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true)
class SecurityConfig : WebSecurityConfigurerAdapter() {
companion object {
private const val REMEMBER_ME_KEY = "basdrwerdadev$#@safasfewrahl"
}
@Autowired private lateinit var authenticationProvider: AuthenticationProvider
@Autowired private lateinit var userDetailsService: UserDetailsService
...也许我失去了依赖?我添加了Spring安全依赖项
发布于 2020-10-01 10:16:38
我要检查的前两件事是:
( i)您的自定义身份验证提供程序是否被注释为服务/组件(即spring能看到和管理它吗?)
扩展了spring的AuthenticationManager接口吗?
https://stackoverflow.com/questions/64153034
复制相似问题