authenticationManager无法注入问题
问题:
在更换spring-boot-auto-config的版本从1.5.13升级至2.0.6的过程中出现问题
- ***************************
- APPLICATION FAILED TO START
- ***************************
- Description:
- Field configurers in org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration required a bean of type 'org.springframework.security.authentication.AuthenticationManager' that could not be found.
- The injection point has the following annotations:
- - @org.springframework.beans.factory.annotation.Autowired(required=true)
- Action:
- Consider defining a bean of type 'org.springframework.security.authentication.AuthenticationManager' in your configuration.
解决方法:
添加一下配置类WebSecurityConfig, 使用 Spring Security,一般自己会有该配置类,添加@Bean AuthenticationManager 即可。
- @Configuration
- public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
- @Bean
- @Override
- public AuthenticationManager authenticationManagerBean() throws Exception {
- return super.authenticationManagerBean();
- }
- }