To bootstrap a Spring MVC application, you have to enable Spring built-in DisptachServlet.
Serlvet 3.0 provides a new feature ServletInitializer to configure web applciation without web.xml.
Spring has its WebApplicationInitializer interface, there are a few classes implement this interface, AbstractAnnotationConfigDispatcherServletInitializer includes configuration of Spring Dispatch Servlet, and leaves some room to customize DispatchServlet.
Declare a AbstractAnnotationConfigDispatcherServletInitializer bean.
getRootConfigClasses specifies the configuration classes should be loaded for the Spring infrastrucuture.
getServletConfigClasses specifies the configurations depend on Servlet specification, esp, web mvc related configurations.
getServletMappings is the Spring DispatchServlet mapping URL pattern.
getServletFilters are those Web Filters will be applied on the Spring DispatchServlet.
Spring MVC DispatchServlet is configured in the super classes, explore the details if you are interested in it.
In getServletConfigClasses, we specify a WebConfig will be loaded, which is responsible for configuring Spring MVC in details, including resource handling, view, view resolvers etc.
Generally, WebMvcConfigurerAdapter is the extension point left for users to use for customizing MVC configurations.
Spring Data project provides a SpringDataWebConfiguration which is a subclass of WebMvcConfigurerAdapter and adds pagination, sort, and domain object conversion support. Open the source code of SpringDataWebConfiguration and research yourself.
The following is the full source code of WebConfig.
Jackson2ObjectMapperBuilder provides fluent APIs to configure which features will be enabled or disabled for serialization and deserialization. For the complete configurable options, check the javadocs of SerializationFeature and DeserializationFeature.