上传jar包到nexus私服
程序员文章站
2024-01-11 16:51:04
...
1、Maven配置
在maven/conf/settings.xml中,增加私服的相关配置
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<mirrors>
<mirror>
<id>releases</id>
<name>aliyun maven</name>
<url>http://192.168.199.178:8081/repository/maven-releases/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>snapshots</id>
<name>aliyun maven</name>
<url>http://192.168.199.178:8081/repository/maven-snapshots/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
2、工程pom.xml配置
<!--定义snapshots库和releases库的nexus地址-->
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://192.168.199.178:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://192.168.199.178:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
建议pom文件中加入maven-source-plugin,这样上传私服的时候源码一起打包,引用的时候可以down源码下来,debug调试的时候方便,不用在单独下载
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
3、上传jar包
如果有如下提示就说明上传成功了:
我们到Nexus 上验证一下:
如果更新时间跟刚才上传jar包时间对得上,则说明jar包已经成功上传了!
上一篇: Java数据结构算法题