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