我正在尝试按照这个tutorial在我刚刚开始的web应用程序中设置OAuth身份验证,我是spring的新手,并且一直在挠头为什么OAuth2AuthorisationServerConfig类不能接受bean。
@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;
....
}这两个类在同一个包中
发布于 2016-10-07 02:30:12
在OAuth2AuthorisationServerConfig类上,我用@ComponentScan对其进行了注释,这似乎解决了问题
https://stackoverflow.com/questions/39885411
复制相似问题