Setting Up a Private Maven Repository with Nexus

Understanding Maven

Apache Maven is a project management tool that simplifies build processes through a Project Object Model (POM). It standardizes project structures, manages dependencies, and automates builds, documentation, and reporting.

Private Repository Ovreview

A private repository acts as a local cache for remote artifacts, reducing external dependencies and improving build speeds within a team environment.

Nexus Repository Manager

Nexus is a robust Maven repository manager that:

  • Proxies remote repositories
  • Hosts internal artifacts
  • Manages dependencies efficiently

Installation Steps

  1. Prerequisites

    • JDK 1.8 installed
    • Maven configured
  2. Nexus Setup

    # Download and extract
    wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
    tar -zxvf latest-unix.tar.gz -C /opt/
    
    # Start Nexus
    cd /opt/nexus-*/bin/
    ./nexus start
    
  3. Configuration

    • Access via http://localhost:8081
    • Default credentials: admin/admin123
    • Modify /opt/nexus-*/etc/nexus-default.properties for port changes
  4. Repository Types

    • Proxy: Mirrors remote repositories
    • Hosted: Stores internal artifacts
    • Group: Combines multiple repositories

Integration with Maven

  1. Settings.xml Configuration

    <servers>
      <server>
        <id>nexus</id>
        <username>admin</username>
        <password>admin123</password>
      </server>
    </servers>
    
  2. Project POM Configuration

    <distributionManagement>
      <repository>
        <id>nexus</id>
        <url>http://localhost:8081/repository/maven-releases/</url>
      </repository>
      <snapshotRepository>
        <id>nexus</id>
        <url>http://localhost:8081/repository/maven-snapshots/</url>
      </snapshotRepository>
    </distributionManagement>
    
  3. Deploying Artifacts

    # For releases
    mvn clean deploy
    
    # For third-party JARs
    mvn deploy:deploy-file \
      -DgroupId=com.example \
      -DartifactId=library \
      -Dversion=1.0.0 \
      -Dpackaging=jar \
      -Dfile=path/to/library.jar \
      -Durl=http://localhost:8081/repository/maven-releases/ \
      -DrepositoryId=nexus
    

Repository Management

  • Blob Stores: Physical storage locations
  • Security: User/role management
  • System: Maintenance and monitoring

Tags: Maven Nexus devops java Repository Management

Posted on Wed, 12 Aug 2026 16:18:53 +0000 by fatal