2012-11-20 54 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)来缓存和聚合构建所需的第三方仓库。