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格式如下:
<span class="pln">
</span><span class="tag">&lt;settings</span><span class="pln"> </span><span class="atn">xmlns</span><span class="pun">=</span><span class="atv">"http://maven.apache.org/SETTINGS/1.0.0"</span><span class="pln">
 </span><span class="atn">xmlns:xsi</span><span class="pun">=</span><span class="atv">"http://www.w3.org/2001/XMLSchema-instance"</span><span class="pln">
 </span><span class="atn">xsi:schemaLocation</span><span class="pun">=</span><span class="atv">"http://maven.apache.org/SETTINGS/1.0.0
 http://maven.apache.org/xsd/settings-1.0.0.xsd"</span><span class="tag">&gt;</span><span class="pln">
 </span><span class="tag">&lt;localRepository/&gt;</span><span class="pln">
 </span><span class="tag">&lt;interactiveMode/&gt;</span><span class="pln">
 </span><span class="tag">&lt;usePluginRegistry/&gt;</span><span class="pln">
 </span><span class="tag">&lt;offline/&gt;</span><span class="pln">
 </span><span class="tag">&lt;pluginGroups/&gt;</span><span class="pln">
 </span><span class="tag">&lt;servers/&gt;</span><span class="pln">
 </span><span class="tag">&lt;mirrors/&gt;</span><span class="pln">
 </span><span class="tag">&lt;proxies&gt;</span><span class="pln">
  </span><span class="tag">&lt;proxy&gt;</span><span class="pln">
   </span><span class="tag">&lt;id&gt;</span><span class="pln">myproxy</span><span class="tag">&lt;/id&gt;</span><span class="pln">
   </span><span class="tag">&lt;active&gt;</span><span class="pln">true</span><span class="tag">&lt;/active&gt;</span><span class="pln">
   </span><span class="tag">&lt;protocol&gt;</span><span class="pln">http</span><span class="tag">&lt;/protocol&gt;</span><span class="pln">
   </span><span class="tag">&lt;host&gt;</span><span class="pln">your proxy server address</span><span class="tag">&lt;/host&gt;</span><span class="pln">
   </span><span class="tag">&lt;port&gt;</span><span class="pln">your proxy server port</span><span class="tag">&lt;/port&gt;</span><span class="pln">
   </span><span class="tag">&lt;username&gt;</span><span class="pln">your proxy account</span><span class="tag">&lt;/username&gt;</span><span class="pln">
   </span><span class="tag">&lt;password&gt;</span><span class="pln">your proxy password</span><span class="tag">&lt;/password&gt;</span><span class="pln">
   </span><span class="tag">&lt;nonProxyHosts&gt;</span><span class="pln">localhost,127.0.0.1</span><span class="tag">&lt;/nonProxyHosts&gt;</span><span class="pln">
  </span><span class="tag">&lt;/proxy&gt;</span><span class="pln">
 </span><span class="tag">&lt;/proxies&gt;</span><span class="pln">
 </span><span class="tag">&lt;profiles/&gt;</span><span class="pln">
 </span><span class="tag">&lt;activeProfiles/&gt;</span><span class="pln">
</span><span class="tag">&lt;/settings&gt;</span><span class="pln">
</span>
以Eclipse來說,到以下的選單:
Window > Preferences > Maven > User Settings
在這個畫面指定上面的settings.xml

沒有留言:

張貼留言