Setting Up a Maven Repository with Nexus 3

Popular Maven Repository Managers

Three commonly used private repository solutions for Maven include:

  1. Apache Archiva
  2. JFrog Artifactory
  3. Sonatype Nexus (the most widely adoppted)

Installing and Configuring Nexus 3 on Windows with Java 8

Download

Obtain Nexus 3 from the official site:

Setup

After extracting the downloaded archive, perform the following steps:

  1. Set the system environment variable NEXUS_HOME to the extracted directory path.

    echo %NEXUS_HOME%
    # Example output: D:\devtools\nexus-3.58.1-02-win64\nexus-3.58.1-02
    
  2. Add %NEXUS_HOME%\bin to the system PATH.

  3. Adjust port and context path settings in %NEXUS_HOME%\etc\nexus-default.properties:

    application-port=8081
    application-host=0.0.0.0
    nexus-context-path=/
    
  4. Optionally tune JVM parameters in %NEXUS_HOME%\etc\nexus.vmoptions. Default memory allocation is sufficient for basic usage.

Running Nexus

Start Nexus using one of these commands:

nexus.exe /run          # Run in console mode
nexus.exe /install      # Install as Windows service
nexus.exe /start        # Start installed service

Access the web interface at http://localhost:8081/ after startup.

On first launch, an initial admin password will be generated in:

%NEXUS_HOME%\sonatype-work\nexus3\admin.password

Use this to log in; you'll be prompted to change it upon first acces.

Configuring Aliyun as a Proxy Repository

To use Aliyun's Maven mirror:

  1. Create a new proxy repository in Nexus UI:

    • Select type maven2(proxy)
    • Remote storage URL: https://maven.aliyun.com/repository/central
  2. Add the newly created proxy repo to the maven-public group under Repositories > Groups.

  3. Update your local Maven configuration (%MAVEN_HOME%/conf/settings.xml) with server credentials and mirrors:

    <servers>
      <server>
        <id>maven-snapshots</id>
        <username>your_username</username>
        <password>your_password</password>
      </server>
      <!-- Repeat for releases and public repos -->
    </servers>
    
    <mirrors>
      <mirror>
        <id>nexus-central-proxy</id>
        <mirrorOf>*</mirrorOf>
        <url>http://localhost:8081/repository/maven-public/</url>
      </mirror>
    </mirrors>
    

Deploying Artifacts

To publish builds to Nexus, update your project's pom.xml:

<distributionManagement>
  <snapshotRepository>
    <id>maven-snapshots</id>
    <url>http://localhost:8081/repository/maven-snapshots/</url>
  </snapshotRepository>
  <repository>
    <id>maven-releases</id>
    <url>http://localhost:8081/repository/maven-releases/</url>
  </repository>
</distributionManagement>

Then execute deployment command:

mvn deploy

Successful execution uploads artifacts to the specified repositories.

Tags: Maven Nexus Repository Management Java Build Tools devops

Posted on Tue, 18 Aug 2026 16:30:52 +0000 by anna_cm