centos7 sonatype nexus3 (support maven, nuget, docker, etc.) private server setup



I can't download it. It should be blocked by the firewall. I uploaded another package

Direct docker is OK

tar.gz mode deployment

tar -xzvf nexus-3.19.1-01-unix.tar.gz
cd nexus-3.19.1-01/bin
#Start service
./nexus start
#Add the 8081 port to the firewall rule (--permanent takes effect, and will become invalid after restarting without this parameter)
firewall-cmd --zone=public --add-port=8081/tcp --permanent 
firewall-cmd --reload


Log in at the upper right corner with the username admin and password sonatype-work/nexus3/admin In the password file

After login, change the new password to admin (to be used later)

Then, Configure Anonymous Access pops up. We allow anonymous access and check Enable anonymous access

From the Browse menu, you can see several warehouses of maven2 (java package) and nuget (.net package)

Sonatype work is the working directory


It should be possible to change the port or something

Upload jar package

web direct upload

After logging in, in the upload menu, you can select maven releases to upload jar packages. Select jar packages, fill in groupid, artifactid, and version, and click upload to upload

Click the gear on the top to enter the setting page, Repository - repositories, click Maven release warehouse, and you can see the warehouse url:

Upload in maven project

Write a maven project

pom. Add project configuration section in XML

    <!-- Use distribution management to print this project into jar Package, directly uploaded to the specified server -->
        <!--Official version-->
            <!-- nexus User name in server: in settings.xml in<server>of id-->
            <!-- This name defines itself -->
            <name>Release repository</name>
            <name>Snapshots repository</name>

User's directory m2/settings.xml configuration (one is not copied from the conf directory of maven)
servers configuration section add


Run mvn deploy and upload to nexus snapshots to upload packages to nexus.

After uploading, you can view the package in Browse or Search on the nexus web interface

maven command direct upload

mvn deploy:deploy-file -DgroupId=org.whq -DartifactId=abc -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=abc-1.0-SNAPSHOT.jar -Durl= -DrepositoryId=nexus-snapshots

Note that the user name and password are also stored in the settings stored in the previous step XML in the server whose id is nexus snapshots

Use private server

Configuring maven images

Images of third-party warehouses such as the central warehouse. The central warehouse corresponds to the Maven central warehouse of nexus (you can see that the proxy agent is configured by opening this warehouse with the admin setting https://repo1.maven.org/maven2/ )

settings. The mirrors section of XML is added. When refreshing maven (downloading maven dependencies), the project will be downloaded from the central warehouse to the nexus server first, and then downloaded locally (you can see that there are already project dependent packages in the nexus server)


pom.xml download the jar package just uploaded

pom. project section configuration in XML

            <name>Snapshots repository</name>

Add dependency


After refreshing, you can see that this package already has

From the user directory m2\repository, delete this package and try downloading again

Tags: Java Docker CentOS Maven

Posted by Blondy on Thu, 02 Jun 2022 10:32:40 +0530