Skip Navigation

Using Sonatype Nexus Repository 3 – Part 1: Maven Artifacts

February 21, 2017 By Rafael Eyng

4 minute read time

This article is the first in a three part series by one of our community advocates, Rafael Eyng. You can follow his work at

NOTE: We are constantly improving Sonatype Nexus Repository. This blog may no longer be accurate. You can find the latest instructions here.


Install it with docker:

docker run -d -p 8081:8081 -p 8082:8082 -p 8083:8083 
--name my-nexus sonatype/nexus3:3.0.0

We are mapping all of those ports (8081-8083) because of the next posts in the series. For this post, we’ll actually only need port 8081.

Sonatype Nexus 3 will go up on port 8081. Default credentials are admin/admin123.

You might want to create a volume to map the Sonatype Nexus data folder to your host, adding the option -v /opt/my-nexus-data:/nexus-data.

Configuring Sonatype Nexus as a Maven repo

What we will do:
– create a private (hosted) repository for our snapshots
– create a private (hosted) repository for our releases
– create a proxy repository pointing to Maven Central
– create a group repository to provide all of these repos under a single URL

I suggest you to create a new blob store for each new repo you want to create. That way, the data for every repo will be in a different folder in /nexus-data (inside the Docker container). But this is not mandatory for it to work.

snapshots repo

A repository for Maven artifacts that you deploy with -SNAPSHOT in the end of the version tag of your pom.xml:


Create a new maven (hosted) repository and configure it like:


releases repo

A repository for Maven artifact that you deploy without -SNAPSHOT in the end of the version tag of your pom.xml:


Create a new maven (hosted) repository and configure it like:


proxy to Maven Central repo

A repository that proxies everything you download from Maven Central. Next time you download the same dependency, it will be cached in your Sonatype Nexus.

Create a new maven (proxy) repository and configure it like:



group repo

This will group all the above repos and provide you a single URL to configure your clients to download from/deploy to.

Create a new maven (group) repository and configure it like:
You can create as many repos as you need (like proxies to other public repos) and group them all in the group repo.

Configuring your clients and projects to use your Sonatype Nexus repos

Put this in your ~/.m2/settings.xml file. This will configure the credentials to publish to your hosted repos, and will tell your mvn to use your repo as a mirror of central:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns=""




And now configure your projects.

If you want only to download dependencies from Sonatype Nexus, put this in the pom.xml:

<project ...>



And if you want also to publish your project, add:

<project ...>



Now if you run in your projects:

mvn install
# or
mvn deploy

your mvn will point to your Sonatype Nexus instance.

Tags: Maven, Product, Sonatype Nexus Repository, Sonatype Nexus 3

Written by Rafael Eyng