Setting up a Maven Repository using Nexus and Artifactory

by Max Rohde,

Two popular alternatives are Nexus and Artifactory and it is highly debated, which is the best option to use. Nexus seems to have the smaller footprint on the server‘s memory.

Installing Nexus

Download and Install Apache Tomcat (as Windows Service)

You can deploy Nexus as a War file.

The war file is at the bottom of the downloads page

Configuring Nexus

Follow some of the post install steps. Eg change the passwords (also for deployment user etc) and reindex the repositories.

I would also suggest to change the default location, in which repositories are kept. On my Windows 7, Nexus used a very strange folder in systems32/systemprofiles or so. The default location can be changed by changing the file „“. It can be found in the Apache Tomcat folder, under webapps/ nexus / WEB-INF.


The parameter, which needs to be changed is nexus-work:


I would disable anonymous access.

Set up a user „download“ and assign the role „Repo: All Repositories (Read)“. Set a password for the user. eg „example1“.


Configuration of Maven Client to Download Repositories

You will need to change the settings.xml file for your Maven clients.

(1) You need to specify the address of your repository:

<settings xmlns=“”         xmlns:xsi=“”         xsi:schemaLocation=“”>

         localRepositories mxsnapshots mxsnapshots mxreleases mxreleases


HINT: Do not forget the activeProfiles element!

(2) Since we have disabled anonymous access, we will need to specify the authentication information for the servers. Nexus allows you to store the password in an encrypted form. However, here we just specify the passwords in plain text. The servers element can be inserted below or above the profiles element:

mxsnapshots download ... mxreleases download ...

NOTE: In NetBeans the user settings file can be easily edited by right-clicking the „Project Files“ node in a Maven project and selecting „create settings.xml“.

You now should be able to use repositories from your repository in your local projects.

Configure Repository for Third Party Jars

Often, a project depends on a jar, which is not available on the public Maven repositories. In that case, it is the most robust approach to define this library in our Nexus Maven repository.

Nexus creates a special repository „thirdparty“.

We need to add this repository to our local settings.xml as well:

mxthirdparty mxthirdparty true true ...

And add another entry to the servers element:

mxthirdparty download ... ...

Now we can log in to the Nexus web interface. Under repositories, we find the 3rd party repository. We can go to the tab „Artifact Upload“ bildschirmfoto2010-06-01um17-26-19.png

You need to select the „GAV Definition“ GAV Parameter if you do not have a POM for the jar. You must come up with your own group etc meta data. Then you can select the jar file that you want to upload.

Configuration of Maven Client to Upload Projects

To upload to your repository, you have to specify an additional element in your projects pom.xml: the elements can be inserted directly under the project element (and NOT in the build element):

releases Internal Releases snapshots Internal Snapshots

You will further need to specify the authentication, as only the deployment user is allowed to deploy artifacts to the repository. For this, you will need to add new server elements to the settings.xml file:

snapshots deployment ... releases deployment ... thirdparty deployment ...

Now you can deploy the project by using the command „mvn deploy“.

See also this blogpost regarding distributing projects to a local repository.

Installing Artifactory (Incomplete)

You can also check out this screencast.

Download and Install Apache Tomcat (as Windows Service)

Download Artifactory Open Source Maven repository manager

Deploy the artifactory.war to the Tomcat Application using the Tomcat manager.

Click on /artifactory and wait for the application to load

login with admin / password

Go to admin and specify the server name (eg „mymavenreps“)

Go to security and require authentication.

Create a user „maven“ with a password of your choice.

Go to repositories.

Local and remote repositories should already been set up.



You can go back to the home tab and automatically generate settings for Maven there:


Go to your local maven repository:

MacBookMX:workflows mx$ cd ~/.m2/

Create a new file settings.xml there and paste the generate Maven settings.

For me, the generated settings file still defined the server as „localhost“ - I changed it to the actual server where I installed Maven.

Further, you need to specify the user login information of the user you have created before.

How your local jar files can be uploaded to the server is described in this screencast.

Further Resources

Blog post on why to use dependency management. And another blog post on the same topic.

Tutorial Setting Up Maven Repository under Windows using Artifactory

Good overview of how to configure repositories on the client side (Codehaus)

Categories: java