我应该如何在maven项目中安装缺失的工件

时间:2011-03-23 18:20:32

标签: maven

运行mvn clean install

时出现以下错误
Missing:
----------
1) org.apache.maven.shared:maven-invoker:jar:2.0.6

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.apache.maven.shared -DartifactId=maven-invoker -Dversion=2.0.6 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.apache.maven.shared -DartifactId=maven-invoker -Dversion=2.0.6 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:2.0-alpha-4
    2) org.apache.maven.shared:maven-invoker:jar:2.0.6

2) org.apache.maven.archetype:archetype-common:jar:2.0-alpha-4

  Try downloading the file manually from the project website.

  Then, install it using the command: 
      mvn install:install-file -DgroupId=org.apache.maven.archetype -DartifactId=archetype-common -Dversion=2.0-alpha-4 -Dpackaging=jar -Dfile=/path/to/file

  Alternatively, if you host your own repository you can deploy the file there: 
      mvn deploy:deploy-file -DgroupId=org.apache.maven.archetype -DartifactId=archetype-common -Dversion=2.0-alpha-4 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

  Path to dependency: 
    1) org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:2.0-alpha-4
    2) org.apache.maven.archetype:archetype-common:jar:2.0-alpha-4

----------
2 required artifacts are missing.

for artifact: 
  org.apache.maven.plugins:maven-archetype-plugin:maven-plugin:2.0-alpha-4

from the specified remote repositories:
  nexus (http://nexus.browsermob.com/content/groups/public/)



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Wed Mar 23 14:16:32 EDT 2011
[INFO] Final Memory: 11M/81M
[INFO] ------------------------------------------------------------------------

3 个答案:

答案 0 :(得分:1)

这些工件在主maven存储库中可用:maven-invoker:2.0.6archetype-common:2.0-alpha-4,它们应该自动解析。

您的问题是这个Nexus存储库:http://nexus.browsermob.com。我无权访问它,但必须将其配置为代理maven central repository。如果您是BrowserMob的员工,请询问负责Nexus服务器的人员。如果不是 - 只需从pom.xmlsettings.xml全局删除此存储库。您可以成功构建项目。

答案 1 :(得分:1)

看起来您正在使用的存储库(http://nexus.browsermob.com/content/groups/public/)不包含一些常见的maven插件。

您有几个选择:

  1. 配置nexus.browsermob.com repo,以便代理来自maven central的工件
  2. 将maven中央存储库添加到本地设置文件中
  3. 如果您想使用选项2,请将其添加到您的设置文件的<repositories>部分(通常位于.m2/settings.xml的主文件夹中):

    <repository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <url>http://repo1.maven.org/maven2</url>
    </repository>
    

    并将其转入<pluginRepositories>部分:

    <pluginRepository>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
        <id>central</id>
        <url>http://repo1.maven.org/maven2</url>
    </pluginRepository>
    

答案 2 :(得分:0)

只需将“http://nexus.browsermob.com/content/groups/public/”粘贴到您的网络浏览器,然后查看其中的库列表。你会看到库不存在,或者版本号不同。(这很有可能。)

Soultion是:

玩得开心。