springSecurityFilterChain nullPointer Exception

前端 未结 2 2031
無奈伤痛
無奈伤痛 2021-01-21 11:51

When I try to run project, the Tomcat return an exception.

Some one can help with this problem? Configuration class: https://github.com/intrade/inventory/blob/master/sr

相关标签:
2条回答
  • 2021-01-21 12:28

    Did you implement the filters in your web.xml?

     <filter>
            <filter-name>springSecurityFilterChain</filter-name>
            <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
        </filter>-->
        <filter-mapping>
            <filter-name>springSecurityFilterChain</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
    
    0 讨论(0)
  • 2021-01-21 12:38

    The issue is related to SEC-2382 and can be resolved by updating to Spring Security 3.2.0.RELEASE. For reference, you will want to update the SecurityConfig as shown below:

    @Configuration
    @EnableWebSecurity
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
    
        @Autowired
        private DataSource dataSource;
    
        @Autowired
        private UserDetailsService myCustomUserDetailsService;
    
        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
            auth
                .jdbcAuthentication()
                    .dataSource(dataSource)
                    .and()
                .userDetailsService(myCustomUserDetailsService);
        }
    
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                .authorizeRequests()
                    .antMatchers("/app/**").hasRole("ADMIN")
                    .and()
                .formLogin()
                    .loginPage("/index.jsp")
                    .defaultSuccessUrl("/app/")
                    .failureUrl("/index.jsp")
                    .permitAll()
                    .and()
                .logout()
                    .logoutSuccessUrl("/index.jsp");
        }
    
    }
    
    0 讨论(0)
提交回复
热议问题