【问题标题】:Maven Proxy errorMaven 代理错误
【发布时间】:2016-01-29 05:47:50
【问题描述】:

您好,我无法在我的机器中创建 Maven 项目。以下是我的配置

Eclipse Version: Mars.1 Release (4.5.1)
Maven Version: m2e, Maven Integration for Eclipse, 1.6.2

我支持公司代理。我试图在 .m2 目录中配置设置文件,但它不起作用。下面是我的设置文件

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<proxies>
 <proxy>
 <id>myproxy</id>
 <active>true</active>
 <protocol>http</protocol>
 <host>XX.XX.XX.XX</host>
 <port>8080</port>
 <nonProxyHosts></nonProxyHosts>
 <username>USERNAME</username>
 <password>PASSWORD</password>
 </proxy>
 </proxies>

</settings>

我在 StackOverflow 中看到了很多关于这个问题的答案,我试过了,但没有任何效果。我怀疑,我的密码中有'@'字符,它会导致任何问题吗?我们还需要提供 USERNAME 作为 domain\USERNAME 还是只提供 USERNAME ?以及如何在文件中同时提供http和https?

堆栈跟踪错误

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): connect timed out

【问题讨论】:

  • 你能分享一个堆栈跟踪或错误吗?您是否尝试在 CDATA 块中添加密码?示例:&lt;![CDATA[password]]&gt;
  • 添加了堆栈跟踪错误。
  • 我遇到了同样的问题。参考这个答案stackoverflow.com/a/41395286/3141502

标签: java eclipse maven proxy


【解决方案1】:

根据我的经验。

  1. “@”字符不是关键问题。因为我的密码也包含此字符。
  2. 不需要添加域
  3. 其实也许你可以这样试试:

在你的 IDE(例如:eclipse)中配置代理信息,而不是在 settgins.xml 中配置,这意味着删除你的 maven 设置文件中的所有配置

【讨论】:

  • 我也试过这个。我的 eclipse 网络连接设置显示来自系统代理的代理信息。
  • 我假设您的系统代理是指向您公司代理地址的链接。像这样:proxyconf.company.com 如果你只使用它是不正确的。请将此链接粘贴到您的浏览器,将获得一个包含您所有代理主机的文件。用它来试一试
【解决方案2】:

只需更改解决问题的 maven 安装

  1. 下载maven binaries并解压并相应设置路径变量。

  2. 通过输入 mvn 检查命令提示符或终端是否有效!

  3. 在提取的二进制包 conf 目录中编辑 settings.xml。

  4. 导航到 windows -> 首选项 -> maven 首选项 -> 安装

  5. 使用正确的路径添加新安装到提取的 maven 二进制文件夹。

这样你就不会再遇到任何问题了!

【讨论】:

    【解决方案3】:

    在我的情况下,我只是执行了以下步骤并且它有效。

    1. 在eclipse和maven(/user/.m2/settings.xml)中提到了代理细节
    2. 然后从 /user/.m2/repository 中删除所有 *.lastupdated 文件
    3. 之后它工作正常

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-05
      • 1970-01-01
      • 2020-10-08
      • 2015-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多