Skip Navigation
Resources Blog Spring, Maven & Nexus Best Practices

Spring, Maven & Nexus Best Practices

Today [Keith][1] posted an [entry about obtaining Spring 3 artifacts with Maven][spring3Artifacts] using the method of sourcing Maven repositories from inside POMs. I wanted to suggest an alternative for Spring users which draws upon best practices that we've developed over time with our enterprise clients doing large builds with a healthy number of developers on the team. Putting repositories in POMs generally looked dimly upon and I consider it an anti-pattern for enterprise build & release. I won't go into the details here but instead refer you to [Brian Fox's][2] [blog entry on the matter][pomsInRepos].

The alternative I would suggest is use a repository manager like [Nexus][nexus] and proxy the Spring repositories that you are interested in using. I would assume that at some point in time a team might be interested in releases, milestones and snaphot repositories. So at [Nexus OSS][nexusoss] I setup the three Spring repositories as you see below:

SpringRepos.png

You then might want to use a single URL in your Maven settings to represent the set of Spring repositories as you can see below:

SpringGroup.png

Most organizations though end up having a single URL for developers where all the repositories you might use are managed in a single location. Sonatype has some documentation in the Nexus book for [configuring your developers to use a single group][nexusGroup]. This is usually the way large organizations manage their developers when working with Maven, but I just wanted to show how easy it is to create proxies and manage them together in groups with Nexus.

I know that the vast majority of Spring users are Maven users so I hope this helps get their Maven-based environments setup in a best-practices fashion.

[1]: http://twitter.com/kdonald
[2]: http://twitter.com/brian_fox
[spring3Artifacts]: http://blog.springsource.com/2009/12/02/obtaining-spring-3-artifacts-with-maven/
[pomsInRepos]: http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/
[nexusGroup]: http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html
[nexus]: http://nexus.sonatype.org
[nexusoss]: http://oss.sonatype.org

Picture of Jason van Zyl

Written by Jason van Zyl

Jason is a co-founder and the former CTO of Sonatype.