**
security学习第一天
我使用的是前后端不分离方式----脚手架方式还没有使用习惯。我碰到了几个bug
- 项目启动时候爆出这样的错误:authenticationManager must be specified
我查看源码时候
由于我的security配置类继承了WebSecurityConfigurerAdapter。在这个类里面有一个方法是生成这个对象的
public AuthenticationManager authenticationManagerBean() throws Exception {
return new WebSecurityConfigurerAdapter.AuthenticationManagerDelegator(this.authenticationBuilder, this.context);
}
`按照我的理解应该是生成一个``authenticationManager 对象
```java
//自定义的表单登录页面配置
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login.html")
.loginProcessingUrl("/login")
.permitAll()
.and()
.csrf().disable();
http.addFilterAt(getLoginConfig(), UsernamePasswordAuthenticationFilter.class); //这里将系统拦截器给替换了
}
```UsernamePasswordAuthenticationFilter。。由于我自定义的拦截器没有声明authenticationManager 对象,所以报错最后解决办法
![解决办法](https://img-blog.csdnimg.cn/20210508212223740.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzI2NTYyNzYz,size_16,color_FFFFFF,t_70#pic_center)
在配置LoginConfig定义好authenticationManager 对象