【问题标题】:Maven install for jar creation failureMaven 安装 jar 创建失败
【发布时间】:2018-02-16 16:51:54
【问题描述】:

我正在尝试 Maven 安装并为我的项目创建 jar。但我收到以下错误:

 Plugin org.apache.maven.plugins:maven-surefire-plugin:2.19.1 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-surefire-plugin:jar:2.19.1: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.19.1 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org: unknown error: Unknown host repo.maven.apache.org: unknown error -> [Help 1]

任何帮助表示赞赏。我发现了类似的线程,但没有一个有效。添加了如下缺少的插件,但仍然是同样的问题。任何帮助表示赞赏。

插件添加:

<plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.19.1</version>
        </plugin>
    </plugins>

提前致谢。

【问题讨论】:

  • 看起来你在基于这个的代理/防火墙后面:`未知主机repo.maven.apache.org:未知错误->`...
  • 检查您的网络设置(代理如上所述)。有时也有助于从本地 Maven 存储库中删除有问题的工件目录。
  • @khmarbaise 如何添加代理设置并使其工作有什么建议吗?
  • @khmarbaise 添加了代理并且它有效。非常感谢。请发表您的评论作为答案。会接受它,它可能会帮助其他一些人。再次感谢

标签: java maven maven-2 maven-3 maven-plugin


【解决方案1】:

正如 khmarbaise 和 lexicore 已经提到的,您需要为 maven 配置代理。请确认您在贵公司的网络上。如果是这样:

找出你的代理

如果您使用公司的笔记本电脑,您的浏览器可能已经配置为使用公司代理。这是一个很好的wikihow article,用于在不同的浏览器中查找您的代理设置。你不想接受:

  • 代理服务器主机名
  • 代理服务器端口
  • 代理服务器用户名(如果有)
  • 代理服务器密码(如果有)

如果您的浏览器中没有通过常规方法配置代理,您应该联系您的 IT 部门并询问他们代理服务器的详细信息。

为 maven 配置代理

完成代理服务器设置后。打开您的~/.m2/settings.xml 文件。如果它不存在,请创建它。现在使用以下格式填写您的代理服务器的详细信息:

<settings>
  <proxies>
   <proxy>
      <id>work-proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>my.proxy.host.name</host>
      <port>proxyport</port>
      <username>proxyuser</username> <!-- Remove this option if there is no user name -->
      <password>somepassword</password> <!-- Remove this option if there is no password -->
    </proxy>
  </proxies>
</settings>

这方面的官方 maven 文档是 here。

注意:如果您将工作笔记本电脑带回家并且没有通过 VPN 连接到公司网络,则必须禁用此代理才能让 maven 在家工作。

【讨论】:

  • 这解决了这个问题。感谢所有贡献的人:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多