首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法自动布线。没有找到'AuthenticationProvider‘类型的bean

无法自动布线。没有找到'AuthenticationProvider‘类型的bean
EN

Stack Overflow用户
提问于 2020-10-01 09:57:44
回答 1查看 879关注 0票数 0

我不能在我的AuthenticationProvider类中自动创建一个SecurityConfig Spring框架实例。这很奇怪,因为我已经包含了必要的导入,并且UserDetailsService (另一个Spring类)可以自动处理,不会出现任何问题。这是我的密码:

代码语言:javascript
运行
复制
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安全依赖项

EN

Stack Overflow用户

回答已采纳

发布于 2020-10-01 10:16:38

我要检查的前两件事是:

( i)您的自定义身份验证提供程序是否被注释为服务/组件(即spring能看到和管理它吗?)

扩展了spring的AuthenticationManager接口吗?

票数 2
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64153034

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档