Setting up a Maven Repository Manager with Artifactory

As you start to work more with Maven, you will undoubtedly reach the point where you feel the need for a repository manager – something that manages all of your repositories of artifacts for you.  You will likely have a few repositories for different types of artifacts that you care about.

There are a few repository managers out there, with varying capabilities, and some with commercial and free/community versions.  In this post, we will use the community version of Artifactory from JFrog.

So the scenario here is that we are going to set up a binary repository to do three things:

  • act as a mirror/proxy of Maven Central
  • hold our work in progress project builds (snapshots)
  • hold our finished products and other dependencies

We will set up Artifactory with three repositories for these three uses, named:

  • repo1
  • snapshot
  • internal

Let’s get started by downloading Artifactory from here.

You can just download the zip file, then unzip it, and start up Artifactory by running the command:

<ARTIFACTORY_DIRECTORY>/bin/artifactoryctl start

You will need to replace <ARTIFACTORY_DIRECTORY> with the path to the
directory where you unzipped Artifactory.

Artifactory will start up and should be accessible at:


The first thing you will want to do is login as the admin user (the password is password).  Then click on the Admin tab to go to the administration area.  If you have to go through an HTTP proxy to get to Maven Central, you will need to define the proxy server details.  You can do this in the Proxies page – click on Proxies in the left hand menu.

Then click on the New button, give the proxy a name (key) and fill out the server, port and any other details needed to use the proxy server.

Next, you need to go set the repo1 mirror to use this proxy server.  To do this, go to the Repositories page, find repo1 in the Remote Repositories section, highlight it, click on Edit in the popup menu, go to the Advanced Settings tab, and in the Network section, choose the proxy you just defined from the dropdown list.

If you do not need to use a proxy server, you can continue from this point.

If you are not already there, click on the Admin tab and then the Repositories option in the left menu.

In the Local Repositories section (at the top), click on the New button and create a new repository called internal.  Select the option to Handle Releases, but do not select Handle Snapshots.

Create another new local repository called snapshot, select the option to Handle Snapshots, but not Handle Releases.

So we have our repositories set up.  Now we are going to want to create a Maven settings file to use them.

First, let’s create a master password so that we can store encrypted passwords in our Maven settings file.  Run the following command:

mvn -emp some_password

Change ‘some_password’ to a password of your own choosing.  Copy the output of this command and put it into a new file in $HOME/.m2/settings-security.xml as follows:


Note that your encrypted password will be different to the one shown here.

Now you can encrypt passwords for accessing servers, like our Artifactory server.  You will need to authenticate to publish new artifacts into the internal and snapshot repositories.  By default, the admin user has the right to publish to these repositories, so you can encrypt the admin user’s password (which is password) as follows:

mvn -ep password

Copy the output of this command, we will need it later on.

Let’s take a look at the Maven settings file that lets us use our Artifactory server:


So let’s review what we have in this file.  First we have a profile, called default, which sets up the repositories and tells Maven which ones handle snapshots and releases.  Then we activate that profile.

Then we have a mirror entry to tell Maven where to look for any artifact it wants from central.

Finally, we have the servers section which is used to provide credentials for accessing servers.  In this case we are providing the encrypted admin user password so that we can publish to these repositories.

Save this file in $HOME/.m2/settings.xml and we are ready to test it out!

To test the mirror, you can use the following command:

mvn help:describe

Ultimately this command will produce an error message, because we have not provided enough arguments, but before that happens, it will need to go download a bunch of artifacts from central, and to do that, it will request them from your mirror.  After this command has started running, you can browse the repo1 repository in the Artifactory web interface and you will see it starting to fill up with the various artifacts that Maven needs to execute that command.

So, that tells us that our mirror is working.  Next, let’s try to publish a release artifact to the internal repository.  You could use the Maven Synchronization Plugin as an example.  This will be sitting in your WebLogic Server installation, under $ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3

You can install it into the internal repository using this command:

mvn deploy:deploy-file

After running this command, you can browse the internal repository in the Artifactory web interface and you will see the plugin in there.

Finally, let’s test our snapshot repository.  To do that, we need a new project.  Grab a new directory, and create a project using one of the simple archetypes, like maven-archetype-quickstart for example. You can do this using this command:

mvn archetype:generate

Then, go into your project1 directory, and add the following distributionManagement section to your pom.xml:


Now you can deploy the project!  Run this command:

mvn deploy

Then go browse your snapshot repository and you will see your project’s artifact in there!

So that completes the basic setup of a Maven repository manager using Artifactory and configuration of Maven to use it.  Enjoy!

About Mark Nelson

Mark Nelson is a Developer Evangelist at Oracle, focusing on microservices and messaging. Before this role, Mark was an Architect in the Enterprise Cloud-Native Java Team, the Verrazzano Enterprise Container Platform project, worked on Wercker, WebLogic and was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s