美文网首页
Spring Security无法注入authenticatio

Spring Security无法注入authenticatio

作者: 芯茹芷氺 | 来源:发表于2018-07-02 13:34 被阅读0次

出错提示:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}

注入申明:

@Autowired

privateAuthenticationManager authenticationManager;

解决方案:

在WebSecurityConfigurerAdapter的实现类当中,重写authenticationManagerBean方法:

@Bean(name = BeanIds.AUTHENTICATION_MANAGER)

@Override

publicAuthenticationManagerauthenticationManagerBean() throws Exception {

    return super.authenticationManagerBean();   

}

参考:

https://stackoverflow.com/questions/21633555/how-to-inject-authenticationmanager-using-java-configuration-in-a-custom-filter

相关文章

网友评论

      本文标题:Spring Security无法注入authenticatio

      本文链接:https://www.haomeiwen.com/subject/cvqwhxtx.html