美文网首页
springboot (备忘录) 2.4.6 升级 2.5.1

springboot (备忘录) 2.4.6 升级 2.5.1

作者: 逮到兔子的狐狸 | 来源:发表于2021-07-01 11:58 被阅读0次

    记录一个错误
    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);
        }
    
    ...
    }
    

    相关文章

      网友评论

          本文标题:springboot (备忘录) 2.4.6 升级 2.5.1

          本文链接:https://www.haomeiwen.com/subject/wisjultx.html