Creating a Spring MVC using the JavaConfig approach
After creating the Spring MVC backbone using the XML-based ApplicationContext, this recipe will highlight the JavaConfig equivalent of the same baseline project.
Getting started
Create a web.xml-less Spring web project using the processes established in the Implementing a Spring container recipe using JavaConfig. Configure appropriately and correctly the pom.xml file so that the project will no longer use web.xml. Deploy the blank project first and verify if there are errors before doing this recipe.
How to do it...
Perform the following to build a simple Spring MVC project using the JavaConfig specification:
- Create the
JavaConfigroot context through implementing the abstract classorg.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter. It has the@Configurationannotation and contains methods that can be overridden to manage validators, view resolvers, controllers, interceptors, and other MVC-specific components needed to...