Referencing Spring Security configuration within Spring 3.1 Java Config

后端 未结 4 680
盖世英雄少女心
盖世英雄少女心 2021-02-04 21:12

I recently switched a majority of my Spring configuration to use the code based config in Spring 3.1. However, now that I\'ve switched, my Spring Security is not working correc

4条回答
  •  悲&欢浪女
    2021-02-04 21:23

    I got it working with Spring 3.2.3 and Servlet 3.0. The tick is to extend DelegatingFilterProxy class and named it SpringSecurityFilterChain.

    public class ServiceInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
    
    @Override
    protected Class[] getRootConfigClasses() {
        return new Class[] { ApplicationConfig.class };
    }
    
    @Override
    protected Class[] getServletConfigClasses() {
        return new Class[] { WebConfig.class };
    }
    
    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }
    
    @Override
    protected Filter[] getServletFilters() {
        return new Filter[] { new OpenEntityManagerInViewFilter(), new SpringSecurityFilterChain() };
    }
    
    public class SpringSecurityFilterChain extends DelegatingFilterProxy {
    
    }
    

    }

提交回复
热议问题