打开%m2_home%/bin/settings.xml,增加如下一段:
<proxies>
<!-- 使用代理上网 -->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>192.168.1.1</host>
<port>8081</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
host、port、username、password不用说,nonProxyHosts就是例外地址。
如果bin下面没有settings.xml,手工新建一个,完整的setting.xml如下:
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository />
<interactiveMode />
<usePluginRegistry />
<offline />
<pluginGroups />
<servers />
<proxies>
<!-- 使用代理上网 -->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<username></username>
<password></password>
<host>192.168.1.1</host>
<port>8081</port>
<nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
</proxy>
</proxies>
<profiles />
<activeProfiles />
</settings>
完成后保存,再往c:\document and setting\\.m2\下面复制一份即可。