电光石火-穿越时空电光石火-穿越时空


Spring Security无法注入authenticationManager

Description:
Field authenticationManager in xxx.auth.config.MyAuthorizationConfig required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.

Action:
Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.


注入申明

@Autowired
private AuthenticationManager authenticationManager;

解决方案

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

@Bean(name = BeanIds.AUTHENTICATION_MANAGER)
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
}
本博客所有文章如无特别注明均为原创。作者:似水的流年
版权所有:《电光石火-穿越时空》 => Spring Security无法注入authenticationManager
本文地址:http://ilkhome.cn/index.php/archives/386/
欢迎转载!复制或转载请以超链接形式注明,文章为 似水的流年 原创,并注明原文地址 Spring Security无法注入authenticationManager,谢谢。

评论