pom文件沒有配置distributionManagement:
發布倉庫一般分為Releases版和snapshot版,所以要配置2個倉庫地址
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>corp nexus-releases</name>
<url>http://你的nexusIP:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshot</id>
<name>corp nexus-snapshot</name>
<url>http://你的nexusIP:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
在setting.xml中添加配置:
<servers>
<!-- 發布Releases版的賬號,ID要與distributionManagement中的Releases ID一致 -->
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>******</password>
</server>
<!-- 發布snapshot版的賬號,ID要與distributionManagement中的snapshot ID一致 -->
<server>
<id>nexus-snapshot</id>
<username>admin</username>
<password>******</password>
</server>
</servers>
默認密碼是 deployment123,也可以自定義密碼,然后去Nexus后台修改對應的密碼,在登陸后界面左側Security下的Users下修改密碼。
其實本人已經配置了上面這些內容,但依然報錯的原因其實是我的項目是多模塊的,我只在一個模塊的pom里配置了distributionManagement,但是我卻用另一個模塊打包,當然會報錯。