Skip to content

Spring MVC Maven Archetype

I’ve started using Spring MVC as my main web development framework. I’ve found it straightforward to learn and pleasant to use. However, I was a little disappointed that no standard Maven Archetype exists to quickly set up a new Spring MVC project from scratch.

A while back when I was learning Tapestry 5, I was astonished at how easy it is to create and run a demo Tapestry 5 project using the Tapestry Quickstart Maven archetype. One of the first things I looked for when learning Spring MVC was a similar Maven archetype. Unfortunately SpringSource have not provided one. Fortunately, Spring and Spring MVC have a very active user community and various developers have made their own archetypes available.

kolorobot/spring-mvc-quickstart-archetype

A great Spring MVC quickstart archetype is available on GitHub, courtesy of kolorobot. Good instructions are provided on how to install it to your local Maven repo and use it to create a new Spring MVC project. He’s even helpfully included the Tomcat 7 Maven plugin in the archetypical project so that the newly created Spring MVC can be run from the command line without having to manually deploy it to an application server.

In less than five minutes and just three Maven commands, I was able to create, compile and run a fully working example Spring MVC application. As I’m new to Spring MVC, it was great to start from a simple working application.

Kolorobot’s example application includes the following:

Java based container configuration

Spring’s new configuration mechanism – an alternative to the old XML based configuration.

Annotation based controllers

Controllers defined using annotations rather than by implementing interfaces or overriding base classes.

Annotation based field validation

Field validation based on JSR-303 / Hibernate Validator

Published inHow To

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *