How to upload jar package to maven private server

1. Configure the settings file of maven

<servers>

<server>

<id>releases</id>

<username>deployment</username>

<password>deployment123</password>

</server>

<server>

<id>snapshots</id>

<username>deployment</username>

<password>deployment123</password>

</server>

</servers>

The id corresponds to the warehouse id of nexus private server. If you want to upload to other warehouses, you also need to configure the settings in the settings file.

The user name and password correspond to the user name and password set in nexus. In Security->Users, right-click the corresponding user name -> Set Password to set.

2. Modify warehouse permissions

You need to change the corresponding warehouse permissions to Allow Redeploy, click on the warehouse name -> Configuration

3. Configure the pom.xml file

<repositories>

<repository>

<id>nexus</id>

<name>nexus</name>

<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>nexus</id>

<name>nexus</name>

<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

<releases>

<enabled>true</enabled>

</releases>

<snapshots>

<enabled>true</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

<distributionManagement>

<repository>

<id>releases</id>

<name>User Project Release</name>

<url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>

</repository>

<snapshotRepository>

<id>snapshots</id>

<name>User Project SNAPSHOTS</name>

<url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>

</snapshotRepository>

</distributionManagement>

4. Upload jar package command

mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=jdbc14 -Dversion=1.0.0 -Dpackaging=jar -Dfile=C:\Users\wangc\.m2\repository\mysql\mysql-conn

ector-java\5.1.42\mysql-connector-java-5.1.42.jar -Durl=http://127.0.0.1:8081/nexus/content/repositories/releases/ -DrepositoryId=releases -X

Among them, DgroupId and DartifactId constitute the coordinates of the jar package in pom.xml, and the project is positioned by these two attributes.

Dfile represents the absolute path of the jar package to be uploaded.

The location of the warehouse on the Durl private server, open the nexus->repositories menu, you can see the path.

DrepositoryId represents the warehouse id, which can be found in the configuration information of nexus.

-X means output all logs, if there is an error, you can see the detailed error information

Note: If the error Cannot deploy artifact from the local repository is reported, it is because the jar and pom to be installed cannot be located in the directory of the local repository. Copy the jar and pom to be installed to other directories before installing.

In addition to uploading jar packages, you can also pom

mvn deploy:deploy-file -Dfile=[your file] -DgroupId=[xxxx] -DartifactId=[xxxx] -Dversion=[xxxx] -Dpackaging=[pom|jar|other] -DrepositoryId=[id] -Durl= [repo url]