Java tips, observations, bugs and problems from the world of Spring, Weblogic, Oracle, MySQL and many other technologies...

Wednesday, 21 September 2011

Dissecting Spring's MVC Project POM

One of the good things about Spring’s STS is that is provides a whole bunch of useful Spring project templates that you can use to generate empty or stub projects from which to start writing some code. The list of projects includes a ‘Simple Spring Utility Project’ and a ‘Spring Batch Admin WebApp’.

I’ve not had need to generate all these types of project, but I know that when you create a ‘Spring MVC Project’, you get a complete Maven webapp with a very complete POM file.

Opening up the WebApp’s pom.xml the first thing that strikes you is what a lot stuff you get - value for money or what? The file contains loads of dependencies and plugins and all kinds of stuff and it's all just to build a simple webapp. It does make you wonder whether it’s all needed, especially when you’re sitting in a cafe’ waiting whilst the empty application shell is downloading an endless string of JARs via a 3G connection.

This blog takes a look at the webapp’s POM file and tries to shed a little more light on what’s in there and why, and I’ve done that by commenting the original POM, which is below.

I guess that the pom.xml should really be taken for what it is: a working sample. Most organisations I’ve come across generally organise their POM files in to some kind of hierarchy with a super-pom at the top containing the most general dependencies such as compiler plugin and version, or JUnit version etc, down to individual project POMs with the idea being that, to sprinkle in a few cliche's, you can line all your ducks up in a row, without duplicating effort and repeating yourself