如何为Maven依赖项设置URL

时间:2015-02-17 13:28:41

标签: java maven vagrant maven-3

启动mvn clean install vagrant:up后出现以下错误:

Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/apache/avalon/framework/avalon-framework-api/4.2.0/avalon-framework-api-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-api:pom:4.2.0' in repository snapshot-repository (https://oss.sonatype.org/content/repositories/snapshots)
Downloading: http://central.maven.org/maven2/org/apache/avalon/framework/avalon-framework-api/4.2.0/avalon-framework-api-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-api:pom:4.2.0' in repository Avalon-repo (http://central.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/apache/avalon/framework/avalon-framework-api/4.2.0/avalon-framework-api-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-api:pom:4.2.0' in repository central (http://repo1.maven.org/maven2)
Downloading: https://oss.sonatype.org/content/repositories/snapshots/org/apache/avalon/framework/avalon-framework-impl/4.2.0/avalon-framework-impl-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-impl:pom:4.2.0' in repository snapshot-repository (https://oss.sonatype.org/content/repositories/snapshots)
Downloading: http://central.maven.org/maven2/org/apache/avalon/framework/avalon-framework-impl/4.2.0/avalon-framework-impl-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-impl:pom:4.2.0' in repository Avalon-repo (http://central.maven.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/apache/avalon/framework/avalon-framework-impl/4.2.0/avalon-framework-impl-4.2.0.pom
[INFO] Unable to find resource 'org.apache.avalon.framework:avalon-framework-impl:pom:4.2.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Unable to get dependency information: Error in metadata for artifact 'rubygems:vagrant:gem': Unable to parse version '[0.5.2,0.5.2.0.0.0.0.1)' for dependency 'rubygems:archive-tar-minitar:gem': Range defies version ordering: [0.5.2,0.5.2.0.0.0.0.1)
  rubygems:vagrant:gem:1.0.7

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  rubygems (http://rubygems-proxy.torquebox.org/releases),
  snapshot-repository (https://oss.sonatype.org/content/repositories/snapshots),
  Avalon-repo (http://central.maven.org/maven2)

Path to dependency: 
    1) downloader:downloader:jar:0.0.1-SNAPSHOT
    2) net.ju-n.maven.plugins:vagrant-maven-plugin:maven-plugin:1.0.1

我搜索了这个依赖项,我在另一个网址中找到了它,但我不知道如何设置它。我不想手动下载jar,因为我们使用的是Jenkins而且我无法访问该存储库。

任何人都知道如何解决它?

谢谢!

P.S。我的pom.xml是(部分):

<dependency>
  <groupId>net.ju-n.maven.plugins</groupId>
  <artifactId>vagrant-maven-plugin</artifactId>
  <version>1.0.1</version>
  <type>maven-plugin</type>
</dependency>
<dependency>
  <groupId>de.saumya.mojo</groupId>
  <artifactId>gem-maven-plugin</artifactId>
  <version>1.0.7</version>
</dependency>   
<dependency>
  <groupId>avalon-framework</groupId>
  <artifactId>avalon-framework-impl</artifactId>
  <version>4.2.0</version>
  <optional>true</optional>
</dependency>

Update1:​​我的pom.xml中有以下存储库:

<repositories>      
    <repository>
        <id>snapshot-repository</id>
        <name>Maven2 Snapshot Repository</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
            <updatePolicy>daily</updatePolicy>
        </snapshots>
    </repository>

    <repository>
      <id>Avalon-repo</id>
      <url>http://central.maven.org/maven2</url>
    </repository>
  </repositories>

Update2: Maven在http://repo1.maven.org/maven2/org/apache/avalon/framework/avalon-framework-impl/4.2.0/avalon-framework-impl-4.2.0.pom中寻找依赖关系的问题,但正确的网址为:https://repo1.maven.org/maven2/avalon-framework/avalon-framework-api/4.2.0/avalon-framework-api-4.2.0.pom

3 个答案:

答案 0 :(得分:0)

settings.xm文件夹下有.m2 l。您必须在此处添加存储库,如下所示:

</repository>
                  <repository>
                      <id>central</id>
                      <name>Maven Repository Switchboard</name>
                      <url>http://repo1.maven.org/maven2</url>
                      <snapshots>
                        <enabled>false</enabled>
                      </snapshots>
                    </repository>

答案 1 :(得分:0)

您需要在pom.xml中添加此代码

<repositories>
    <repository>
        <id>appfuse-snapshots</id>
        <url>http://oss.sonatype.org/content/repositories/appfuse-snapshots</url>    // Replace it with your respective repository
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

答案 2 :(得分:0)

我遇到了这个问题,我的依存关系查找失败。因为这是将org.xxx替换为org / xxx,并且没有依赖项被拉出。

默认的Central Maven存储库的URL为http://repo.maven.apache.org/maven2/。 除非您要从其他位置获取工件(例如本地工件等),否则请删除该部分,否则您仍然可以拥有

       <repository> 
           <id>central</id>
           <url>http://repo.maven.apache.org/maven2/</url>
       </repository>

MVN全新安装 它应该下载您要查找的所有存储库。