如何从https://repo1.maven.org更新Maven以获取依赖关系?

时间:2016-01-26 20:09:29

标签: maven clojure maven-dependency-plugin

我尝试使用mvn dependency:get下载JAR,但我在尝试时收到以下错误。

错误消息的关键部分似乎是:

Access denied to: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar , ReasonPhrase:Use https://repo1.maven.org.

但我不确定如何使用repo1.maven.org。我需要做什么?

$ mvn dependency:get -Dartifact=org.apache.maven:maven-profile:2.0.2 -DremoteRepositories=repo1.maven.org
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building clojure 1.8.0-master-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:get (default-cli) @ clojure ---
[INFO] Resolving org.apache.maven:maven-profile:jar:2.0.2 with transitive dependencies
Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.667 s
[INFO] Finished at: 2016-01-27T09:03:30+13:00
[INFO] Final Memory: 16M/304M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.8:get (default-cli) on project clojure: Couldn't download artifact: Could not transfer artifact org.codehaus.plexus:plexus-utils:jar:1.1 from/to central (https://repo.maven.apache.org/maven2): Access denied to: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar , ReasonPhrase:Use https://repo1.maven.org.
[ERROR] org.codehaus.plexus:plexus-utils:jar:1.1
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots, releases=false, snapshots=true),
[ERROR] central (https://repo.maven.apache.org/maven2, releases=true, snapshots=false),
[ERROR] temp (repo1.maven.org, releases=true, snapshots=true),
[ERROR] snapshots (http://snapshots.maven.codehaus.org/maven2, releases=false, snapshots=true),
[ERROR] apache.snapshots (http://cvs.apache.org/maven-snapshot-repository, releases=false, snapshots=true)
[ERROR] Path to dependency:
[ERROR] 1) org.apache.maven.plugins:maven-downloader-plugin:jar:1.0
[ERROR] 2) org.apache.maven:maven-profile:jar:2.0.2
[ERROR] 3) org.codehaus.plexus:plexus-utils:jar:1.1
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException


$ mvn -v
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-11T05:41:47+13:00)
Maven home: /usr/local/Cellar/maven/3.3.9/libexec
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.3", arch: "x86_64", family: "mac"

1 个答案:

答案 0 :(得分:1)

您的Maven pom.xml包含一个如下所示的部分。将repo.maven.apache.org替换为repo1.maven.org。

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