The Nexus2 can upload jar packages to a private library through the admin interface, while the latest Nexus3 does not have an upload interface and can only be published to a private library in the following way.

Publish third-party JAR packages

In this case, maven remote repository does not have third-party JAR packages that need to be published to a private repository.

MVN deploy:deploy-file -DgroupId=com.example -DartifactId= test-dversion =0.0.1 -Dpackaging=jar - Dfile = E: \ workspace \ test \ WebRoot \ WEB - INF \ lib \ test - 0.0.1. Jar - Durl=http://nexus.example.com: 8081 / repository / 3 rd - repo / -DrepositoryId=NexusCopy the code

Publish your own project

The company’s own projects need to be published to the Nexus private library for others to rely on, so you can use the above method to first jar and then publish, or you can use Maven’s Eclipse plug-in.

Add maven POM configuration:

<distributionManagement>
    <repository>
        <id>Nexus</id>
        <name>Releases</name>
        <url>http://nexus.example.com:8081/repository/maven-releases</url>
    </repository>
    <snapshotRepository>
        <id>Nexus</id>
        <name>Snapshot</name>
        <url>http://nexus.example.com:8081/repository/maven-snapshots</url>
    </snapshotRepository>
</distributionManagement>
Copy the code

Then use Run As.. >Maven build.. Enter deploy and publish in Goals.

Maven Settings configuration

Nexus refers to the MAVEN server ID, which is case-sensitive. Add the following configuration.

<servers>

    <server><id>Nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

</servers>
Copy the code

Check out the previous Maven highlights series on how to use Maven and build a private repository.

Recommended reading

Dry goods: 2TB architect four-stage video tutorial

Interview: the most complete Java multithreaded interview questions and answers

Interview: the most comprehensive ali advanced Java interview questions in history

Interview: The most complete Spring interview questions in history

Tutorial: The most complete Spring Boot complete video tutorial

Books: 15 must-read books for advanced Java architects

Tools: Recommended an online creation flow chart, mind mapping software

Share Java dry goods, high concurrency programming, hot technology tutorials, microservices and distributed technology, architecture design, blockchain technology, artificial intelligence, big data, Java interview questions, and cutting-edge hot news.