我正在尝试按照此tutorial关于在我刚刚开始使用的网络应用程序中设置OAuth身份验证,我是一个相当新的春天,并且一直在考虑为什么OAuth2AuthorisationServerConfig
班不能拿起豆。
@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;
....
}
这两个类在同一个包中
答案 0 :(得分:0)
在OAuth2AuthorisationServerConfig类中,我用@ComponentScan注释了它,这似乎解决了这个问题