如何设置行家代理(How to set maven proxy)

2019-10-18 10:37发布

我试图设置行家代理在NetBeans 7.4,因为我背后的代理。 我安装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]

在我的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>

Answer 1:

这可能是一个NTLM代理? 如果是:

请从旅行车HTTP轻质-2.2.jar http://repo.maven.apache.org/maven2/org/apache/maven/wagon/wagon-http-lightweight/2.2/wagon-http-lightweight-2.2。罐

复制车皮HTTP轻量级-2.2.jar到%M2_HOME%/ lib / ext目录文件夹中。



Answer 2:

如你所说。 您正在使用NetBean作为IDE。 请在IDE中使用Maven的。 也许你正在使用嵌入式Maven插件 。 那么它甚至不会更改下的settings.xml工作

/Users/username/.m2/settings.xml



Answer 3:

设置在$ MAVEN_HOME / conf文件夹或whetever你存储settings.xml文件settings.xml文件的代理。

在settings.xml,添加此部分(它可以在任何地方内加入<settings></settings>

<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



文章来源: How to set maven proxy
标签: maven proxy