java.lang.IllegalArgumentException: authenticationManager cannot be null
在学习springSecurity自定义配置类的时候,启动报错:java.lang.IllegalArgumentException: authenticationManager cannot be null
报错的代码:
@Configuration
@EnableWebFluxSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.authorizeRequests().anyRequest().authenticated().and().formLogin().and().httpBasic();
}
@Override
protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
authenticationManagerBuilder.inMemoryAuthentication().withUser("spring").password("{noop}123456").roles("admin");
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
return super.authenticationManagerBean();
}
}
解决:去掉@EnableWebFluxSecurity注解