Hands-On Spring Security 5 for Reactive Applications
上QQ阅读APP看书,第一时间看更新

Step 7—Spring MVC setup

In Spring MVC, the request lands on DispatcherServlet. DispatcherServlet can be declared in web.xml or as a Java configuration if your servlet container is 3.0+. Please create a dummy SpringSecurityConfig.java file. We will be constructing this class when we explain the first authentication mechanism, namely, basic authentication:

public class SpringMvcWebApplicationInitializer
extends AbstractAnnotationConfigDispatcherServletInitializer {

@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { ApplicationConfig.class, SpringSecurityConfig.class };
}

@Override
protected Class<?>[] getServletConfigClasses() {
return new Class[] { WebApplicationConfig.class };
}

@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}

}