执行顺序AuthorizationServerConfigurerAdapter->WebSecurityConfigurerAdapter导致AuthenticationManager依赖注入空指针(oauth2)

oauth2的依赖版本:

<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.2.RELEASE</version>
</dependency>

  单独在启动引导类上import,指定加载顺序

@SpringBootApplication
@Import({WebSecurityConfigurer.class, AuthorizationServerConfigurer.class})
public class SpringBootApplication {
public static void main(String[] args) throws UnknownHostException {
SpringApplication.run(SpringBootSecurityOauth2AuthApplication.class, args);
}
对应的认证服务器
//@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfigurer extends AuthorizationServerConfigurerAdapter {
...
}
//@Configuration
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
...
}

  

执行顺序AuthorizationServerConfigurerAdapter->WebSecurityConfigurerAdapter导致AuthenticationManager依赖注入空指针(oauth2)

原文:https://www.cnblogs.com/cmmplb/p/15245564.html

以上是执行顺序AuthorizationServerConfigurerAdapter->WebSecurityConfigurerAdapter导致AuthenticationManager依赖注入空指针(oauth2)的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>