[maven] Adding maven nexus repo to my pom.xml

First of all I can highly recommend reading the Nexus book. It will explain the benefits of using a Maven repository manager.

There is a section on how to configure your Maven build to use Nexus:

This leads me to question why you altering your POM file? I suspect what you really want to do is setup Nexus as a remote repository mirror. This is done in your Maven settings file.

The following tells Maven use Nexus as your default repository (Instead of Maven Central)

<settings>
  ..
  ..
  <mirrors>
    <mirror>
      <id>nexus</id>
      <url>http://localhost:8081/nexus/content/groups/public</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

This is desired behaviour since your Nexus repository is configured to cache artifacts retrieved from Central (which is good for build performance).

Note:

  • The "public" repository group could include other repositories proxied by your Nexus instance (Not just Maven Central). You probabily want this behaviour, as it centralizes all repository management. It just makes your build less portable for people outside of your organization.