2013-08-01 181 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