maven deploy到nexus報錯:Return code is: 401, ReasonPhrase:Unauthorized

提交到nexus時候報錯:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project : Failed to deploy artifacts: Could not transfer artifact :jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file: http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client /1.0/-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原來是沒有配置認證。

maven目錄conf的setting.xml里,

 <server>  
    <id>releases</id>  
    <username>admin</username>  
    <password>admin123</password>  
  </server>  
 <server>  
  <id>snapshots</id>  
  <username>admin</username>  
  <password>admin123</password>  
  </server>  
</servers>  

用戶名和密碼都是nexus的。再次deploy即可。
注意這里的id要和pom.xml里遠程deploy的地址對應(yīng)一致,我的pom.xml里配置:

<!-- 配置遠程發(fā)布到私服,mvn deploy -->  
    <distributionManagement>  
        <repository>  
            <id>releases</id>  
            <name>Nexus Release Repository</name>  
            <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>  
        </repository>  
        <snapshotRepository>  
            <id>snapshots</id>  
            <name>Nexus Snapshot Repository</name>  
            <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>  
        </snapshotRepository>  
    </distributionManagement> 

如果這里不配置,會報錯:
報錯:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Spring Cloud為開發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,644評論 19 139
  • 首先私服是一種衍生出來的特殊的Maven遠程倉庫,構(gòu)建私服的好處請看3.5私服 可以幫助大家建立私服的倉庫管理軟件...
    zlcook閱讀 10,827評論 0 32
  • 1 依賴 1.1 denpendency包含的元素 1.2 依賴范圍 scope java程序有三種classpa...
    AAA建材王總閱讀 1,184評論 1 0
  • |-1-更新內(nèi)容[6.從倉庫解析依賴的機制(重要)] 1Maven倉庫作用 倉庫用來存儲所有項目使用到構(gòu)件,在ma...
    zlcook閱讀 6,464評論 0 25
  • +load是在整個APP運行期間只調(diào)用一次,在main之前,有分類先本類,再分類,不做任何事情就會被調(diào)用+init...
    RhythmMaster閱讀 1,379評論 0 1

友情鏈接更多精彩內(nèi)容