download
https://help.sonatype.com/repomanager2/download/download-archives—repository-manager-oss
https://www.sonatype.com/products/repository-oss-download
https://download.sonatype.com/nexus/3/latest-unix.tar.gz
I can't download it. It should be blocked by the firewall. I uploaded another package
Direct docker is OK
https://hub.docker.com/r/sonatype/nexus3/
tar.gz mode deployment
#decompression 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 #Reload firewall-cmd --reload
visit
http://ip:8081/
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
Profile:
sonatype-work/nexus3/etc/nexus.properties
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: http://10.0.1.151:8081/repository/maven-releases/
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 --> <distributionManagement> <!--Official version--> <repository> <!-- nexus User name in server: in settings.xml in<server>of id--> <id>nexus-releases</id> <!-- This name defines itself --> <name>Release repository</name> <url>http://10.0.1.151:8081/repository/maven-releases/</url> </repository> <!--snapshot--> <snapshotRepository> <id>nexus-snapshots</id> <name>Snapshots repository</name> <url>http://10.0.1.151:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
User's directory m2/settings.xml configuration (one is not copied from the conf directory of maven)
servers configuration section add
<server> <id>nexus-releases</id> <username>admin</username> <password>admin</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin</password> </server>
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=http://10.0.1.151:8081/repository/maven-snapshots/ -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)
<mirror> <id>nexus-central</id> <mirrorOf>central</mirrorOf> <name>local-central</name> <url>http://10.0.1.151:8081/repository/maven-central/</url> </mirror>
pom.xml download the jar package just uploaded
pom. project section configuration in XML
<repositories> <repository> <id>nexus-snapshots</id> <name>Snapshots repository</name> <url>http://10.0.1.151:8081/repository/maven-snapshots/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories>
Add dependency
<dependency> <groupId>org.whq</groupId> <artifactId>abc</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
After refreshing, you can see that this package already has
From the user directory m2\repository, delete this package and try downloading again