2013-08-01 158 views
1

我试图在NetBeans 7.4中设置Maven代理,因为我在代理之后。我在工具>选项>常规>代理设置中设置NetBeans中的代理,并且工作正常。但是当我尝试构建我的项目时,我仍然遇到错误。如何设置Maven代理

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> 
+0

请发布你的maven本地仓库settings.xml –

+0

添加代理设置 – thinwa

回答

1

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

/Users/username/.m2/settings.xml

+0

浪费3个小时后,我记得我已经指出我的eclipse IDE中的maven,所以从现在开始,我能够从eclipse IDE运行构建,但是从命令提示符处,它给了我下面提到的错误。由于:org.eclipse.aether.transfer.ArtifactTransferException:无法传输 –

1

设置在settings.xml文件的代理在$ MAVEN_HOME工作/ conf文件夹或无论您正在存储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