【问题标题】:Maven fails to connect to repositories (I think)Maven 无法连接到存储库(我认为)
【发布时间】:2016-12-22 09:46:27
【问题描述】:
  1. 我开始在 win 8.1 上做 this 教程。
  2. 我下载了 JDK8 和 Maven。
  3. 我设置了 Maven(将 mvn 添加到 PATH,设置 JAVA_HOME)。

    • mvn --version 的输出:

      Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T18:41:47+02:00) Maven home: C:\apache\apache-maven-3.3.9\bin\.. Java version: 1.8.0_122-ea, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.8.0_122\jre Default locale: en_US, platform encoding: Cp1255 OS name: "windows 8.1", version: "6.3", arch: "amd64", family: "dos"

  4. 为项目创建文件夹。

  5. 尝试运行此命令(从教程中复制粘贴,忽略 SO 中的换行符):mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp -DarchetypeGroupId=org.apache.maven.archetypes -DinteractiveMode=false -DgroupId=com.example.employees -DartifactId=employees-app -DarchetypeVersion=1.0

    • 命令输出:pastebin
    • 输出摘要:No plugin found for prefix 'archetype' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\yogevl\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]

SO 中的答案假定我有一个代理。我没有,我检查了here。另外,我可以使用 Chrome 访问repo。 另一个答案建议以管理员身份运行 cmd。我做了 - 结果相同。

我还关注了输出末尾的link

  1. 不要这么想,因为我是从教程中复制粘贴过来的。
  2. 同上。
  3. 同上。
  4. 不确定这个 - settings.xml 是默认文件。我需要改变它吗?
  5. 同 1-3。

感谢您的帮助!

【问题讨论】:

  • 不要把链接放到 pastebin 等,因为有些人无法访问它们。更好地将帖子输出到 SO...中的帖子中......
  • 我正在使用代理,我从 lagado.com(您提供的测试链接)得到了这个结果:代理测试:这个请求似乎不是通过代理来的。 你是在办公室还是在家里?
  • 这看起来像 https 证书错误。我猜repo.maven.apache.org/maven2 使用的 CA 权限在您的 java cacerts 文件中不受信任,但在 chrome 中受信任。这是一个让您入门的好链接:commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art032 但您需要 repo.maven.apache.org 的证书而不是 maven.2xoffice.com
  • @I-LOVE-2-REVIVE - 我使用的是 JDK 8 附带的标准 cacerts 文件,我没有任何问题。
  • @JimHawkins 是的,我也是,它工作正常。 imgur.com/gallery/PnvK7v6 :) 不过,如果 Yogev 说他没有使用代理,我的猜测是:stackoverflow.com/a/25912982/3656963

标签: maven


【解决方案1】:

在这里阅读 cmets 后,解决方案是更新 cacerts 文件,因为它缺少 Maven 存储库的正确证书(感谢 I-LOVE-2-REVIVE 的答案和链接)。

所以,如果你有同样的问题,这里有一些事情:

  1. This 文章将指导您如何将证书添加到 cacerts 文件中(再次感谢 I-LOVE-2-REVIVE 的链接)。确保为所需的存储库添加证书。
  2. 请记住,每个 jdk/jde 管理不同的证书列表。
  3. keytool 位于%JAVA_HOME%\bin(一开始我以为是linux shell 工具,其实不是)。

【讨论】:

    【解决方案2】:

    在您的文件 ~/.m2/settings.xml 中插入适当的代理设置(在 Windows 上可能是 C:\Users\you\.m2\settings.xml):

    <settings>
        ...
        <proxies>
            <proxy>
                <id>optional</id>
                <active>true</active>
                <protocol>http</protocol>
                <username></username> <!-- perhaps empty, ask admin  -->
                <password></password>
                <host>proxy.your.company.com</host>
                <port>8080</port>
                <nonProxyHosts>localhost|other.server.com</nonProxyHosts>
            </proxy>
        </proxies>
        ...
    </settings>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-04
      • 2019-01-01
      • 1970-01-01
      • 2017-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-09
      相关资源
      最近更新 更多