Popular Maven Repository Managers
Three commonly used private repository solutions for Maven include:
- Apache Archiva
- JFrog Artifactory
- Sonatype Nexus (the most widely adoppted)
Installing and Configuring Nexus 3 on Windows with Java 8
Download
Obtain Nexus 3 from the official site:
- General download page: https://help.sonatype.com/repomanager3/product-information/download
- Direct link for latest version: https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.67.1-01-java8-win64.zip
Setup
After extracting the downloaded archive, perform the following steps:
-
Set the system environment variable
NEXUS_HOMEto the extracted directory path.echo %NEXUS_HOME% # Example output: D:\devtools\nexus-3.58.1-02-win64\nexus-3.58.1-02 -
Add
%NEXUS_HOME%\binto the system PATH. -
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=/ -
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:
-
Create a new proxy repository in Nexus UI:
- Select type
maven2(proxy) - Remote storage URL:
https://maven.aliyun.com/repository/central
- Select type
-
Add the newly created proxy repo to the
maven-publicgroup under Repositories > Groups. -
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.