记录一个错误
Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.NullPointerException
/**
* spring security配置
*/
public class SecurityConfig extends WebSecurityConfigurerAdapter{
...
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
....
// 添加JWT filter
httpSecurity.addFilterBefore(jwtAuthenticationTokenFilter,
UsernamePasswordAuthenticationFilter.class);
// 添加CORS filter
httpSecurity.addFilterBefore(corsFilter, LogoutFilter.class);
// 这一行不注释掉会报错, 查了一下,好像是因为 corsFilter的顺序本来就高。。。
// corsFilter,JwtAuthenticationTokenFilter 都是继承 OncePerRequestFilter
// httpSecurity.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class);
}
...
}
网友评论