- 我們知道,每個公司都會有自己的工具包或公共包,這種包就可以上傳到公司的maven私服,就不用每個人都去同步開發包了。那麼,怎麼把本地項目打包併發布到私服呢?按照如下步驟就可以輕鬆完成。
1. 在setting.xml文件中增加如下內容:
- <servers>
- <server>
- <!-- 發佈的位置在POM中配置,以ID爲關聯,有很多公用的信息需要配置在POM文件裏,最佳實踐是定義一個公司級別的root pom -->
- <id>nexus</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- <server>
- <id>nexus-snapshots</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- <server>
- <id>thirdparty</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- </servers>
2. 在項目的pom.xml文件中增加如下內容
- <distributionManagement>
- <repository>
- <id>nexus</id>
- <name>local private nexus</name>
- <url>http://192.168.xx.xx:8081/nexus/content/groups/public</url>
- </repository>
- <snapshotRepository>
- <id>nexus-snapshots</id>
- <name>local private nexus snapshots</name>
- <url>http://192.168.xx.xx:8081/nexus/content/groups/public-snapshots</url>
- </snapshotRepository>
- </distributionManagement>
- <span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);"> </span>
3. 在項目的 maven bulider中的Goals輸入如下內容
deploy:deploy-file -DgroupId=com.ivifi.tools -DartifactId=ivifi.tools -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=D:\git\tools\visn.tools\target\ivifi.tools-1.0-SNAPSHOT.jar -Durl=http://192.168.xx.xx:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty