IDEA 部署项目jar至私有maven库
1.在需要上传项目的pom.xml文件添加distributionManagement节点。
<distributionManagement>
<repository>
<!--此名称要和maven settings.xml中设置的ID一致 -->
<id>nexus-releases</id>
<url>http://10.0.12.124:8081/nexus/content/groups/public</url>
</repository>
<snapshotRepository>
<!--此名称要maven settings.xml中设置的ID一致 -->
<id>nexus-snapshots</id>
<url>http://10.0.12.124:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
-
注意:IDEA设置的maven settings.xml文件中需要添加对应maven库配置。
在标签中添加:
<server> <id>nexus-releases</id> <username>admin</username> <password>xxxxx</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>xxxxx</password> </server>
在标签中添加:
<mirror> <id>nexus-releases</id> <mirrorOf>*</mirrorOf> <url>http://10.0.12.124:8081/nexus/content/groups/public</url> </mirror> <mirror> <id>nexus-snapshots</id> <mirrorOf>*</mirrorOf> <url>http://10.0.12.124:8081/nexus/content/repositories/snapshots</url> </mirror>
2.IDEA中打包项目jar包并上传。
-
点击窗口右侧maven标签,点开项目的lifecycle。
-
双击clean清理项目。
-
双击package生成jar包。
-
双击deploy上传jar包。
需要引用jar包,只需要在pom文件添加依赖即可:
<dependency> <groupId>com.xxxx.xxxx</groupId> <artifactId>xxxx</artifactId> <version>xxxx</version> </dependency>
groupId、artifactId、version对应项目打包时的pom文件描述。
-
注意:jar包更新时,修改version号重新打包并上传。