maven设立HTTP代理
maven设置HTTP代理
http://maven.apache.org/
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
- 设置HTTP代理
编辑~/.m2/settings.xml文件(如果没有该文件,则复制$M2_HOME/conf/settings.xml)。添加代理配置如下:
<settings> ... <proxies> <proxy> <id>my-proxy</id> <active>true</active> <protocol>http</protocol> <host>218.14.227.197</host> <port>3128</port> <!-- <username>***</username> <password>***</password> <nonProxyHosts> repository.mycom.com|*.google.com </nonProxyHosts> --> </proxy> </proxies> ... </settings>
这段配置十分简单,proxies下可以有多个proxy元素,如果声明了多个proxy元素,则默认情况下第一个被激活的proxy会生效。这里声明了一个id为my-proxy的代理,active的值为true表示激活该代理,protocol表示使用的代理协议,这里是http。当然,最重要的是指定正确的主机名(host元素)和端口(port元素)。上述xml配置中注释掉了username,password,nonProxyHosts几个元素。当代理服务需要认证时,就需要配置username和password。nonProxyHost元素用来指定哪些主机不需要代理,可以使用"|"符号来分隔多个主机名。此外,该配置也支持通配符,如:*.google.com表示所有以google.com结尾的域名访问都不要通过代理。