Why host your own repository

As teams grow, pulling everything from Maven Central slows builds and wastes bandwidth. A Nexus-backed private repository solves this by caching dependencies, hosting internal artifacts, and letting you proxy regional mirrors for a smoother developer experience.

Install Nexus 3

  1. Download Nexus OSS 3.7+ (requires JDK 17).
  2. Unpack it and note two key paths:
nexus-3.77.1-01/        # application binaries
sonatype-work/nexus3/   # data and config

Control the service with:

./nexus start
./nexus stop
./nexus status

The initial admin password lives in sonatype-work/nexus3/admin.password. Log in once and Nexus will prompt you to change it.

First login and port change

Edit nexus-3.77.1-01/etc/nexus-default.properties to switch the default port (I use 8090). Visit http://localhost:8090 and sign in with admin plus the initial password.

Nexus dashboard

Configure repositories and proxies

Inside the Repositories view:

  • Update proxy repositories such as maven-central to use the Aliyun mirror http://maven.aliyun.com/nexus/content/groups/public/.
  • Create a Hosted repository (e.g. levon-release) for internal artifacts.
  • Build a Group repository (e.g. levon-public) that aggregates both proxy and hosted repos into a single endpoint.

Set up the Aliyun proxy

Configure Maven clients

Update ~/.m2/settings.xml with:

<settings>
  <localRepository>/Users/leivik/Developtools/apache-maven-3.9.9/local_repository</localRepository>

  <servers>
    <server>
      <id>levon</id>
      <username>admin</username>
      <password>admin</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>levon</id>
      <mirrorOf>*</mirrorOf>
      <name>levon-public</name>
      <url>http://localhost:8090/repository/levon-public/</url>
    </mirror>
  </mirrors>
</settings>

Key points:

  • localRepository points Maven to a shared cache location.
  • The <server> id must match what projects declare under <distributionManagement> when publishing artifacts.
  • mirrorOf=* routes all dependency downloads through Nexus.

Maven client configuration

Operational advice

  • Back up sonatype-work regularly.
  • Separate hosted repositories for dev, staging, and production, and gate access via roles.
  • Wire monitoring (email or webhooks) to watch disk usage and repository health.

Wrap-up

With Nexus in place, onboarding a new developer is as simple as dropping the updated settings.xml into ~/.m2. Builds become faster, internal artifacts gain version control, and the team stays independent from flaky network connections.