- Configuring Spring Web MVC application without web.xml (post).
- Cache abstraction has been revised.
- A new "packagesToScan" feature for JPA.
- REST support refinements with respect to URI templates.
- And many more refinements.
As a reference application we are going to migrate Spring MVC Template Project to 100% Java-based container configuration.
- HomeController that redirects to home.jsp page.
- web.xml file where Spring DispatcherServlet (loading servlet-context.xml) and ContextLoaderListener (loading root-context.xml) are specified.
- root-context.xml defining shared resources visible to all other web components.
- servlet-context.xml defining servlet's request-processing infrastructure, and importing controllers.xml configuration file.
- controllers.xml as its name suggests configures controllers.
What we are going to create is a revision of Spring MVC Template Project that instead of setting up project using XMLs, is configured using Java classes. The new directory structure is:
Class that replaces servlet-context.xml file is:
So if you want a 100% Java-based configuration, simply removes web.xml file and creates the WebAppInitializer class, which looks like:
Hope you find the post useful, of course you can create hybrid applications, mixing elements configured in XML way and other ones configured in Java classes.
Two Spring Template Projects are provided, one configuring Spring MVC application in a Java-based fashion and web.xml, and another one 100% Java-based configured.
Spring Template Project no web.xml