【问题标题】:How to set maven proxy如何设置maven代理
【发布时间】:2013-08-01 08:41:19
【问题描述】:

我尝试在 NetBeans 7.4 中设置 maven 代理,因为我在代理后面。我从工具>选项>常规>代理设置在NetBeans中设置代理,它工作正常。但是当我尝试构建我的项目时仍然出现错误。

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

我google了错误信息,然后在maven的settings.xml文件中设置了相同的代理,但又出现了错误。

Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): Not authorized by proxy , ReasonPhrase:Proxy Authentication Required. -> [Help 1]

有谁知道怎么回事?

添加代理设置:

<proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |-->
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxyhost</host>
      <port>8080</port>
      <nonProxyHosts>localhost|*.google.com.*</nonProxyHosts>
    </proxy>
       </proxies>

【问题讨论】:

  • 请发布您的 maven 本地存储库 settings.xml
  • 添加了代理设置。

标签: maven proxy


【解决方案1】:

可能是 NTLM 代理?如果是:

从以下位置下载 wagon-http-lightweight-2.2.jar http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-2.2.jar

将 wagon-http-lightweight-2.2.jar 复制到 %M2_HOME%/lib/ext 文件夹。

【讨论】:

    【解决方案2】:

    如你所说。您正在使用 NetBean 作为 IDE。请检查IDE中使用的maven。也许您正在使用嵌入式 maven 插件。那么即使您更改了

    下的 settings.xml,它也不起作用

    /Users/用户名/.m2/settings.xml

    【讨论】:

    • 在浪费了 3 个小时之后,我记得我已经从我的 Eclipse IDE 中指向了我的 Maven,所以从现在开始我可以从 Eclipse IDE 运行构建,但是从命令提示符它给了我下面提到的错误作者:org.eclipse.aether.transfer.ArtifactTransferException:传输失败
    【解决方案3】:

    在 $MAVEN_HOME/conf 文件夹中的 settings.xml 文件中设置代理,或者在您存储 settings.xml 文件时设置。

    在settings.xml中,添加这个部分(可以在&lt;settings&gt;&lt;/settings&gt;内任意位置添加:

    <proxies>
     <proxy>
        <id>example-proxy</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>172.20.201.42</host>   <!-- add your proxy host IP here -->
        <port>8080</port> <!-- add your proxy host port here -->
        <nonProxyHosts>  <!-- non proxy hosts separated by | (pipe) character -->
          172.*|10.*
        </nonProxyHosts>
      </proxy>
    </proxies> 
    

    您可以在此处找到有关代理的 maven 文档:

    https://maven.apache.org/guides/mini/guide-proxies.html

    【讨论】:

      猜你喜欢
      • 2018-05-12
      • 2016-09-16
      • 1970-01-01
      • 2016-12-29
      • 2023-03-21
      • 2023-02-09
      • 1970-01-01
      • 1970-01-01
      • 2011-05-30
      相关资源
      最近更新 更多