2012-11-20 119 views
6

一般情況下,如何解決未在maven回購庫中找到的資源,是否有另一個可以添加到的回購列表pom.xml?我嘗試了列爲命令行的解決方案,但它沒有起作用,儘管maven將其報告爲SUCCESS。無法在存儲庫中心找到資源(http://repo1.maven.org/maven2)

I tried to build test-analytics, but got error: 

[INFO] task-segment: [install] 
[INFO] ------------------------------------------------------------------------ 
[INFO] [resources:resources {execution: default-resources}] 
[INFO] Using 'UTF-8' encoding to copy filtered resources. 
[INFO] Copying 6 resources 
Downloading: http://repo1.maven.org/maven2/com/google/code/gwt-dnd/gwt-dnd/3.1.1/gwt-dnd-3.1.1.pom 
[INFO] Unable to find resource 'com.google.code.gwt-dnd:gwt-dnd:pom:3.1.1' in repository central (http://repo1.maven.org/maven2) 
Downloading: http://repo1.maven.org/maven2/com/google/code/gwt-dnd/gwt-dnd/3.1.1/gwt-dnd-3.1.1.jar 
[INFO] Unable to find resource 'com.google.code.gwt-dnd:gwt-dnd:jar:3.1.1' in repository central (http://repo1.maven.org/maven2) 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] Failed to resolve artifact. 

Missing: 
---------- 
1) com.google.code.gwt-dnd:gwt-dnd:jar:3.1.1 

    Try downloading the file manually from the project website. 

    Then, install it using the command: 
     mvn install:install-file -DgroupId=com.google.code.gwt-dnd -DartifactId=gwt-dnd -Dversion=3.1.1 -Dpackaging=jar -Dfile=/path/to/file 

    Alternatively, if you host your own repository you can deploy the file there: 
     mvn deploy:deploy-file -DgroupId=com.google.code.gwt-dnd -DartifactId=gwt-dnd -Dversion=3.1.1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id] 

    Path to dependency: 
    1) com.google.testing.testify.risk.frontend:test-analytics:war:1.0-SNAPSHOT 
    2) com.google.code.gwt-dnd:gwt-dnd:jar:3.1.1 

---------- 
1 required artifact is missing. 

for artifact: 
    com.google.testing.testify.risk.frontend:test-analytics:war:1.0-SNAPSHOT 

from the specified remote repositories: 
    central (http://repo1.maven.org/maven2) 



[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Sun Nov 18 21:24:23 EST 2012 
[INFO] Final Memory: 16M/238M 
[INFO] ------------------------------------------------------------------------ 

這是命令和錯誤:您需要了解如何在你的POM文件配置repositories部分

mvn deploy:deploy-file -DgroupId=com.google.code.gwt-dnd -DartifactId=gwt-dnd -Dversion=3.1.1 -Dpackaging=jar -Dfile=gwt-dnd-3.1.1.jar 
[INFO] Scanning for projects... 
[INFO] Searching repository for plugin with prefix: 'deploy'. 
[INFO] ------------------------------------------------------------------------ 
[INFO] Building test-analytics 
[INFO] task-segment: [deploy:deploy-file] (aggregator-style) 
[INFO] ------------------------------------------------------------------------ 
[INFO] ------------------------------------------------------------------------ 
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------ 
[INFO] One or more required plugin parameters are invalid/missing for 'deploy:deploy-file' 

[0] Inside the definition for plugin 'maven-deploy-plugin' specify the following: 

<configuration> 
    ... 
    <url>VALUE</url> 
</configuration> 

-OR- 

on the command line, specify: '-Durl=VALUE' 

[INFO] ------------------------------------------------------------------------ 
[INFO] For more information, run Maven with the -e switch 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 1 second 
[INFO] Finished at: Tue Nov 20 14:10:37 EST 2012 
[INFO] Final Memory: 14M/238M 
[INFO] ------------------------------------------------------------------------ 

回答

16

您對Maven世界有一些基本的理解。所以,回購的簡要總結應該會對你有所幫助。

對於初學者,當您運行maven「開箱即用」時,有兩個存儲庫可用,這就是您所做的。你有1)maven central和2)你的本地回購,即〜/ .m2/repository。本地存儲庫是一種緩存,您在本地構建的工件將通過「mvn install」命令「安裝」到該位置。請注意,「mvn deploy」命令「部署」了一個工件,它就像一個安裝,但意味着將工件放入「遠程存儲庫」中。 Maven Central是一個遠程倉庫,除了您的單個本地倉庫以外,所有倉庫都可以使用,但是您不需要部署它。這是審查,發佈質量文物。

因此,您的構建無法找到谷歌文物。這意味着他們不在Maven Central,儘管你可以檢查。 http://search.maven.org/

如果他們不在那裏,你有幾個選項。

1)「安裝」在本地回購的文物(這應該是你的第一個步驟,因爲它是非常輕量級)

2)運行自己的存儲庫服務器,如聯繫。這是你自己的「遠程倉庫」,你可以「部署」谷歌的東西。

3)找出谷歌的東西是否在另一個公開可用的遠程存儲庫中 - 有幾個重要的東西不在開箱即用的回購定義中,但可以添加它們。

請注意,這三個選項並不是解決方案的不同情況。如果你只是在衝刺或打擊某些東西,我肯定會選擇#1號。如果您正在設置一個認真的開發工作來使用這些工件,那麼您必須至少執行#3,可能#2;如果你真的要大量使用maven,#2對於讓你的生活更輕鬆至關重要。這也是一個很好的教育體驗,因爲大多數的maven的東西,從概念上說,你有自己的回購服務器。

+0

所以這是我做的。 下載了gwt-dnd-3.1.1.jar,並將其放在與pom.xml相同的級別,並運行命令: sudo mvn install:install-file -DgroupId = com.google.code.gwt-dnd -DartifactId = gwt-dnd -Dversion = 3.1.1 -Dpackaging = jar -Dfile = gwt-dnd-3.1.1.jar result = BUILD SUCCESSFUL 現在我該怎麼辦?我仍然沒有戰爭文件,或任何可執行文件實際上運行在../target – kamal

+0

應用程序我不認爲它需要旁邊的pom.xml。 。 。另外,請確認它已安裝到本地存儲庫中;你可以簡單地通過查找來做到這一點。m2/repository/my/maven/groupId/As/Directory/Structure/myArtifact – chad

+0

+1,用於對Maven中關鍵概念的精確闡述。 – Withheld

1

更好的還是考慮設置一個Maven倉庫管理器(比如Nexus)來緩存和聚合構建所需的第三方倉庫。