關於Maven無法上傳快照SNAPSHOT包,You cannot upload a snapshot version into a release repository的解決

我們這裏只講一下利用Nexus搭建的Maven私服處理辦法。
通常上傳自己的jar包,是通過3rd party中Artifact Upload就可以完成,新建一個hosted也是有Artifact Upload可以上傳jar包。
但新建一個snapshot-hosted 卻沒有Artifact Upload可以上傳jar包。
而release庫裏又沒法上傳SNAPSHOT包,所以這裏介紹一下通過maven命令來上傳的方法。

一、需要修改maven安裝目錄下conf裏settings.xml

<!-- 配置遠程倉庫驗證信息 -->
<servers>
  <server>  
    <id>xxxx</id>  
    <username>admin</username>  
    <password>admin123</password>  
  </server>  
  <server>  
    <id>xxxx-snapshot</id>  
    <username>admin</username>  
    <password>admin123</password>  
  </server> 
</servers>

<!-- 配置遠程發佈到私服,mvn deploy--> 
<distributionManagement>  
    <repository>  
        <id>xxxx</id>  
        <name>xxxx</name>  
        <url>http://192.168.xx.xx/content/repositories/xxxx/</url>  
    </repository>  
    <snapshotRepository>  
        <id>xxxx-snapshot</id>  
        <name>xxxx-snapshot</name>  
        <url>http://192.168.xx.xx/content/repositories/xxxx-snapshot/</url>  
    </snapshotRepository>  
</distributionManagement>


二、maven的執行命令
mvn deploy:deploy-file 
-DgroupId=com.xxx
-DartifactId=xxx-core 
-Dversion=1.8.0-SNAPSHOT 
-Dpackaging=jar 
-Dfile=D:/xxx-core-1.8.0-SNAPSHOT.jar 
-Durl=http://192.168.xx.xx/content/repositories/xxxx-snapshot/ 
-DrepositoryId=xxxx-snapshot


Dfile表示需要上傳的jar包的絕對路徑。
Durl私服上倉庫的位置,打開nexus——>repositories菜單,可以看到該路徑。

DrepositoryId服務器的表示id,在nexus的configuration可以看到。

執行命令,如果上傳成功則顯示


不成功也會有相應的提示,如返回401是驗證失敗之類的,要具體來看。

以上,完成了jar包的上傳。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章