Operations 11 min read

Mastering Nexus: Install, Configure, and Use Maven Repository Manager

This guide walks you through the fundamentals of Nexus—its purpose as a Maven repository manager, the structure of local, remote, and central repositories, step‑by‑step installation, essential configuration files, Maven settings integration, artifact deployment, and verification of a fully functional private Maven repository.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Mastering Nexus: Install, Configure, and Use Maven Repository Manager

1. Introduction to Nexus

Nexus is a powerful Maven repository manager that simplifies the maintenance of internal repositories and access to external ones, allowing complete control over artifact deployment and retrieval from a single location.

2. Maven Repository Types

Nexus supports three main repository types:

Local repository : By default located at ${user.home}/.m2/repository (or C:/Users/…/.m2/repository on Windows).

Remote repository : Mirrors external repositories such as Maven Central. Example configuration:

<repositories>
  <repository>
    <id>central</id>
    <name>Central Repository</name>
    <url>http://repo.maven.apache.org/maven2</url>
    <layout>default</layout>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
  </repository>
</repositories>

Mirror configuration to redirect all requests to a private server:

<mirror>
  <id>mirrorId</id>
  <mirrorOf>*</mirrorOf>
  <name>Human Readable Name for this Mirror.</name>
  <url>http://my.repository.com/repo/path</url>
</mirror>

3. Nexus Installation

Download the latest Nexus bundle (e.g., nexus-2.11.2-06-bundle.tar.gz) from the official site, extract it, and note the default storage path /sonatype-work/nexus/storage/central. Edit conf/nexus.properties to set the application port and host, e.g.:

application-port=8086
application-host=0.0.0.0
nexus-webapp-context-path=/nexus
nexus-work=${bundleBasedir}/../sonatype-work/nexus

Adjust the startup script ( bin/nexus) to set RUN_AS_USER (avoid running as root) and apply proper permissions: sudo chmod -R a+x /home/software/nexus-2.11.2-06-bundle/ Start Nexus with: ./nexus start Access the UI at http://<i>ip</i>:8086/nexus/ (default credentials: admin / admin123).

4. Configuring Maven to Use Nexus

Add a mirror and repository definitions to settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <mirrors>
    <mirror>
      <id>UFindNexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
    </mirror>
  </mirrors>
  <servers>
    <server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>
</settings>

Or configure a specific remote repository directly in a project's pom.xml:

<repositories>
  <repository>
    <id>jboss</id>
    <name>JBoss Repository</name>
    <url>http://repository.jboss.org/nexus/content/groups/public/</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>false</enabled></snapshots>
    <layout>default</layout>
  </repository>
</repositories>

5. Deploying Artifacts to Nexus

Define distribution management in the project's pom.xml:

<distributionManagement>
  <repository>
    <id>releases</id>
    <name>Nexus Release Repository</name>
    <url>http://ip:8081/nexus/content/repositories/releases/</url>
  </repository>
  <snapshotRepository>
    <id>snapshots</id>
    <name>Nexus Snapshot Repository</name>
    <url>http://ip:8081/nexus/content/repositories/snapshots/</url>
  </snapshotRepository>
</distributionManagement>

Deploy with Maven commands:

mvn clean deploy
# or, if tests should be skipped
mvn clean install -Dmaven.test.skip=true

6. Verifying the Setup

After running the build, the console shows upload progress, confirming that the JAR has been pushed to the Nexus repository. Browse the Nexus UI to see the newly uploaded artifacts.

These steps provide a complete workflow for installing Nexus, configuring Maven to use it, and deploying artifacts, enabling efficient internal dependency management and bandwidth savings.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ConfigurationInstallationrepository-manager
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.