首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >@限定符未拾取@Bean

@限定符未拾取@Bean
EN

Stack Overflow用户
提问于 2016-10-06 07:53:30
回答 1查看 430关注 0票数 0

我正在尝试按照这个tutorial在我刚刚开始的web应用程序中设置OAuth身份验证,我是spring的新手,并且一直在挠头为什么OAuth2AuthorisationServerConfig类不能接受bean。

代码语言:javascript
运行
复制
@Configuration
public class ServerSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("JL").password("TEST").roles("USER");
    }

    @Override
    @Bean //Here is the bean
    public AuthenticationManager authenticationManagerBean() throws Exception {
        return super.authenticationManagerBean();
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/", "/login", "/register").permitAll()
                .anyRequest().authenticated()
                .and().formLogin().permitAll()
                .and().logout().permitAll();
    }

}

@Configuration
public class OAuth2AuthorisationServerConfig extends AuthorizationServerConfigurerAdapter {

    @Autowired
    @Qualifier("authenticationManagerBean")  // here is the qualifier for bean
    private AuthenticationManager authenticationManager;
    ....
}

这两个类在同一个包中

EN

回答 1

Stack Overflow用户

发布于 2016-10-07 02:30:12

在OAuth2AuthorisationServerConfig类上,我用@ComponentScan对其进行了注释,这似乎解决了问题

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39885411

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档