场景

1. 本地jar包上传到私服

思路:

1. maven的settting.xml配置私服的帐号密码

2. pom.xml配置上传的地址

3. 执行 mvn deploy 部署jar包到私服

步骤:

1. 在${M2_HOME}/conf/setting.xml中配置私服的帐号密码信息,例如:

<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>

记住这个id, 后面在pom.xml指定服务上传的id

2. 配置pom.xml, 如果没有这个文件,则需要将jar包解压,然后在META-INF中可以找到pom.xml文件,修改pom.xml, 增加服务器部署配置:

<distributionManagement>
<snapshotRepository>
<id>deploymentRepo</id>
<url>http://192.168.10.2:8080/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<!--
<repository>
<id>deploymentRepo</id>
<url>http://192.168.10.2:8080/nexus/content/repositories/releases</url>
</repository>
-->
</distributionManagement>

这里的id要和setting.xml中的id对应

3. 在pom.xml的同级目录下,执行:

mvn deploy:deploy-file -DgroupId=com.xxx.xxx -DartifactId=xx-xx-xx -Dversion=0.0.-SNAPSHOT -Dpackaging=jar -Dfile=/home/yinian/jar/xxx/xx.jar -Durl=http://192.168.10.2:8080/nexus/content/repositories/snapshots
-DrepositoryId=deploymentRepo

就可以看到已经上传完毕

maven上传本地jar包到私服-LMLPHP

04-06 04:06