1: Upload the jar package to maven from the command line
In this way, there is a jar package in the maven warehouse, but it is not available through Nexus. If the project uses Nexus to manage Maven, the Nexus address configured in the pom will still not download the jar package)
For example, the pom file is as follows:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
</dependency>
Execute the following command on the command line (pay attention to replace the black part):
mvn install:install-file -Dfile=tools-1.8.0.jar -DgroupId=com.sun -DartifactId=tools -Dversion=1.8.0 -Dpackaging=jar
2: Upload the jar package to maven through nexus
Many pits, tried many methods but failed to upload, and it is related to the nexus version, 3.9 has an upload button on the left side of the figure below, but 3.2 on the right side of the figure below, there is no
Finally, I found a relatively simple and effective way to upload with pom files,
First, you need to create a new repository, for example, I named it four_party
Add to maven-public:
Still the same as 1, upload tools-1.8.0.jar to maven,
The content of the pom file is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8.0</version>
<packaging>jar</packaging>
<name>tools</name>
<description>tools</description>
<distributionManagement>
<repository>
<id>nexus</id>
<name>four_party</name>
<url>http://192.168.20.129:8081/repository/four_party/</url>
</repository>
</distributionManagement>
<!-- 执行mvn deploy即可上传成功! -->
</project>
windows:
In the same level directory of pom, enter the command line window to execute: mvn deploy
linux:
Under the pom same level directory, execute: mvn deploy
See SUCCESS success