2013-04-25 177 views
3

我正在嘗試將第三方供應商的jar添加到我們內部的nexus存儲庫。mvn deploy:deploy-file - 無法部署工件:找不到工件

我試圖這樣做使用這個命令:

mvn deploy:deploy-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar 
-DrepositoryId=Nexus 
-Durl=http://myserver:8888/nexus/content/repositories/thirdparty/ 

在我的settings.xml以下條目:

<servers> 
     <server> 
      <id>Nexus</id> 
      <username>myusername</username> 
      <password>mypassword</password> 
     </server> 
    </servers> 

但我得到這個錯誤:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7: 
deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: 
Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/c 
ontent/repositories/thirdparty) -> [Help 1] 

有什麼建議嗎?

一些相關的信息... 我可以安裝到我的本地庫就好了,使用這個命令:

mvn install:install-file 
-DgroupId=acme 
-DartifactId=acme 
-Dversion=1.0 
-Dpackaging=jar 
-Dfile=C:\tmp\acme-1.0.jar 

我也試過「神器上傳」通過Nexus的網絡界面,使用GAV參數:

Group: acme 
Artifact: acme 
Version: 1.0 
Packaging: jar 

並選擇&添加acme-1.0.jar。 這樣就完成了罰款,但該項目因這個jar結果 「MVN安裝」:

Could not find artifact acme:acme:jar:1.0 in Nexus (http://myserver:8888/nexus/content/groups/public) 

我的POM包含:

<repositories> 
    <repository> 
    <id>Nexus</id> 
    <url>http://myserver:8888/nexus/content/groups/public</url> 
    <releases><enabled>true</enabled></releases> 
    <snapshots><enabled>true</enabled></snapshots> 
    </repository> 
</repositories> 

任何幫助非常讚賞...

PS我知道這個問題與this one非常相似,但問題似乎是使用詹金斯網址,而不是聯網網址。

回答

4

回答我自己的問題。我解決了這個問題,如下所示:

1)如果您在代理服務器後面(即您的maven settings.xml中有代理服務器設置)但您的nexus服務器是內部的,則可能需要將nexus服務器添加爲settings.xml中的nonProxyHost例如

<proxies> 
    <proxy> 
    ... 
    <nonProxyHosts>myserver</nonProxyHosts> 
    </proxy> 
</proxies> 

我意識到我需要做到這一點,因爲"mvn deploy:deploy-file"命令我跑似乎沒有在所有到達關係回購。 例如,我可以在settings.xml的服務器部分中更改回購ID,用戶名或密碼,並且仍然會得到完全相同的錯誤。我也可以將deploy命令中的url更改爲亂碼(例如-Durl=notexist),或者甚至完全關閉我的nexus repo,並且仍然得到相同的錯誤。

2)確保您的第三方存儲庫設置爲發佈,而不是快照。 爲此,請轉至Web GUI,選擇第三方存儲庫的配置選項卡,並確保存儲庫策略設置爲發佈。

我通過查看卡塔利娜發現了這一點。出日誌(我跑關係在Tomcat的戰爭),看到以下內容:

ERROR org.sonatype.nexus.rest.ContentPlexusResource - Got exception during processing request "PUT http://myserver:888/nexus/content/repositories/thirdparty/acme/acme/1.0/acme-1.0.pom": Storing of item thirdparty:/acme/acme/1.0/acme-1.0.pom is forbidden by Maven Repository policy. Because thirdparty is a SNAPSHOT repository 

有了這些2個修復,無論是「MVN部署:部署文件」命令,並上傳通過「上傳文物'在Web GUI工作中的選項。

+0

只是爲了澄清..第三方回購默認情況下是一個版本庫,所以不需要改變它,除非有人將它改爲快照。請始終記住,Nexus Maven存儲庫既可以是快照,也可以是發行版,並使用組將它們混合在一起。 – 2013-04-29 19:37:16

0

登錄到nexus web控制檯並檢查Public Repository配置並查看第三方是否在Ordered Group Repositories列表中。

+0

感謝Bhushan,但我已經在Ordered Group Repositories列表中擁有第三方存儲庫。好的建議,但。 – 2013-04-26 16:05:06

相關問題