google-code-prettify

2015年1月17日 星期六

Maven設定Proxy

到一個新環境,拿到一個新Project source,
 一打開Project冒出下面這樣的錯誤:
ArtifactDescriptorException: Failed to read artifact descriptor for ......
Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6

接著看到pom.xml冒出一堆錯誤...,
有可能是所處的網路環境會經過Proxy Server,
所以可以試著給Maven設定Proxy可以解決這樣的問題。

編寫一個settings.xml格式如下:

<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">
 <localRepository/>
 <interactiveMode/>
 <usePluginRegistry/>
 <offline/>
 <pluginGroups/>
 <servers/>
 <mirrors/>
 <proxies>
  <proxy>
   <id>myproxy</id>
   <active>true</active>
   <protocol>http</protocol>
   <host>your proxy server address</host>
   <port>your proxy server port</port>
   <username>your proxy account</username>
   <password>your proxy password</password>
   <nonProxyHosts>localhost,127.0.0.1</nonProxyHosts>
  </proxy>
 </proxies>
 <profiles/>
 <activeProfiles/>
</settings>

以Eclipse來說,到以下的選單:
Window > Preferences > Maven > User Settings
在這個畫面指定上面的settings.xml

沒有留言:

張貼留言