jar 创建失败的 Maven 安装

Maven install for jar creation failure

我正在尝试为我的项目安装 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]

感谢任何帮助。我发现了类似的线程,但其中 none 有效。添加了如下缺少的插件,但仍然是同样的问题。感谢任何帮助。

已添加插件:

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

提前致谢。

正如 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 在家工作.