首页 > Web开发 > 详细

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

时间:2021-09-10 06:43:19      阅读:16      评论:0      收藏:0      [点我收藏+]

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

(0)
(0)
   
举报
评论 一句话评论(0
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!