First, the Nexus installation
1. Download Nexus (point solution here)
2. Unzip the file after downloading and place the extracted nexus file where you want it
3. Configure environment variables (as with the configuration of Java environment variables)
4. Install and start the Nexus
Because I have installed and started the Nexus, there is an error message
5. After the successful launch, the browser input http://localhost:8081/nexus/will enter the Nexus interface
We can also modify the port in Conf/nexus.properties
6. After successful login with admin, you can see the following interface
We can see that type has multiple types, here we introduce three kinds:
- Hosted, the local repository (also known as the host repository), usually we deploy our own artifacts to this type of warehouse or third-party packages (for example, Oracel).
- Proxies, which are used to proxy remote public repositories, such as the MAVEN central repository.
- Group, warehouse groups, which are used to consolidate multiple hosted/proxy warehouses, typically we configure MAVEN to rely on warehouse groups.
Second, use the Nexus management interface to upload the jar package
Third, create your own private warehouse
Iv. Creation of permissions
V. Create a role
V. Create a user
Vi. associating with their own private warehouses
1. Add the image file association in the settings.xml file
<mirrors> <mirror> <id>nexus-releases</id> <mirrorof>*</mirrorof > <url>http://localhost:8081/nexus/content/groups/public</url> </mirror> <mirror> <id>nexus-snapshots</id> <mirrorof>*</ Mirrorof> <url>http://Localhost:8081/nexus/content/repositories/apache-snapshots /</url> </mirror> </mirrors>
2. Set the profile in the Settings.xml file
</profiles> <profile> <id>nexusTest</id> <repositories> < repository> <id>local-nexus</id> <url>http://127.0.0.1:8081/nexus/ content/groups/public/</url> <releases> <enabled>true</ enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </ Profiles>
<activeProfiles> <!--activate profile--> with ID nexustest
<activeProfile>nexusTest</activeProfile>
</activeProfiles>
Vii. release your own snapshot version to a private warehouse
Here we test to publish the Nexustest.jar to the Myrepository warehouse
1. Add in Pom.xml
<distributionManagement> <!--self-created library--<repository> <id>myreposioryt</i d><!--The ID here is the same as the ID configured in the role-<name>my test reposiory</name> <url> http://localhost:8081/nexus/content/repositories/myrepository</url></repository> <!--snapshots Gallery--<snapshotRepository> <id>nexus-snapshots& lt;/id> <name>nexus Snapshot repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url></snapshotRepository> <!--<repository> <id>nexus-releases</id> <n Ame>nexus Release repository</name> <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url></repository> </distributionManagement>
1. Add in the Settings.xml file
<servers> <server> <id>myReposioryT</id> <!--The ID here is consistent with the Pom.xml Use this account to upload jars to your own build my test reposiory warehouse-- <username>testAdmin</username> <password> 123456</password> </server> <server> <id>nexus-releases</id > <username>admin</username> <password>admin123</password> </ server> <server> <id>nexus-snapshots</id> <username>admin</ username> <password>admin123</password> </server> </servers>
Using the MAVEN package Deploy command, you can publish your project as a jar to your own private repository.
Note that to publish the jar package, you need to change <packaging>war</packaging> to <packaging>jar</packaging>
Appendix:
If you use idea, there are good tools for us to do it.
The use of Nexus and MAVEN configuration