背景:
由於換了一家新單位,java工程上很多工具都沒有部署,於是自己准備部署了一套nexus版本較新(伏筆)嘗試從部署到使用一條路探雷然后給同事做培訓。
按照正常的套路部署完以后配置maven setting文件;
核心配置
<servers>
<server>
<id>Robam_dkb_Release</id>
<username>admin</username>
<password>xxxx</password>
</server>
<server>
<id>Robam_dkb_SnapShort</id>
<username>admin</username>
<password>xxxx</password>
</server>
</servers>
<profiles>
<profile>
<id>nexusProfile</id>
<repositories>
<repository>
<id>central</id>
<url>http://xxxxx/repository/Robam_dkb_group/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexusProfile</activeProfile>
</activeProfiles>
pom文件配置
<distributionManagement>
<repository>
<id>Robam_dkb_Release</id>
<name>Robam_dkb_Release</name>
<url>http://xxxxx/repository/Robam_dkb_Release/</url>
</repository>
<snapshotRepository>
<id>Robam_dkb_SnapShort</id>
<name>Robam_dkb_SnapShort</name>
<url>http://xxxxx/repository/Robam_dkb_SnapShort/</url>
</snapshotRepository>
</distributionManagement>
老公司的地址是http://xxxxx/nexus/content/groups/public/ 這樣的地址 版本是老的
新版本的地址是http://xxxxx/repository/Robam_dkb_SnapShort 一開始是擔心地址的問題
進入正題
maven deploy后出現
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project component: Failed to retrieve remote metadata com.robam.cloud.component:component:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.robam.cloud.component:component:0.0.1-SNAPSHOT/maven-metadata.xml from/to Robam_dkb_SnapShort (http://xxxx/repository/Robam_dkb_SnapShort2/): Transfer failed for http://xxxxx/repository/Robam_dkb_SnapShort2/com/robam/cloud/component/component/0.0.1-SNAPSHOT/maven-metadata.xml 400 Repository version policy: RELEASE does not allow metadata in path: com/robam/cloud/component/component/0.0.1-SNAPSHOT/maven-metadata.xml
因為新版本的index地址其實是http://xxxxx/service/rest/repository/browse/Robam_dkb_SnapShort/所以我嘗試替換地址試試,然后deploy出現了405 Method Not Allowed 直接405了更不對了
然后仔細再看報錯發現0.0.1-SNAPSHOT版本這么會提示RELEASE does not allow metadata呢哪里的對應關系搞錯了?
后來百度各種屬性修改依然不行,配置文件檢查N遍還是沒發現問題。后來發現倉庫新建的時候有個
的屬性,坑爹,預發布倉庫選成了穩定倉庫。最后刪除重建完成。
總結:其實這個問題回過頭冷靜下來想想就該知道,deploy發布既然有預發布和穩定的區別,創建倉庫的時候就應該注意,屬性的編輯。歸根究底還是對maven的管理掌握的不夠透徹。以前是衣來伸手飯來張口使用即可,別人都已經給你把路打平,現在必須要深入一點了解才行。