Maven--为Maven配置HTTP代理

开发者博客: http://www.developsearch.com

在公司要通过设置代理才能上网的环境下,需要为Maven配置HTTP代理才能正常访问外部仓库
1、确认无法直接访问中央仓库:ping repol.maven.org 检查网络
2、检查代理服务畅通:telnet 本机IP 代理端口
3、编辑 ~/.m2/settings.xml文件,添加代理配置如下:
<settings>
	...
		<proxies>
			<proxy>
				<!--id是代理名称-->
				<id>my-proxy</id>
				<!--active表示激活代理-->
				<active>true</active>
				<!--protocol表示使用的代理协议-->
				<protocol>http</protocol>
				<!--代理主机名-->
				<host>192.168.1.95</host>
				<!--代理主机端口-->
				<port>9001</port>
				<!--代理认证用户名-->
				<username>***</username>
				<!--代理认证密码-->
				<password>***</password>
				<!--指定哪些主机名不需要代理
				<nonProxyHosts>repository.mycom.com|*.google.com</nonProxyHosts>
				-->
			</proxy>
		</proxies>
	...
	</settings>



配置本地仓库到D:/maven/
1、修改D:\apache-maven-3.0.4\conf\settings.xml
   <localRepository>D:/maven/repository</localRepository>

2、将修改好的settings.xml文件复制到D:/maven/下

猜你喜欢

转载自keepwork.iteye.com/blog/1561141