Maven 安装 jar 创建失败

测试账号

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

提前致谢。

旅人

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

找出您的代理

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

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

如果您的浏览器中没有通过正常方法配置代理,您应该联系您的 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 文档在这里

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章