让Maven支持代理

1、如果你的公司架设了防火墙并设置了HTTP代理服务器来禁止你们直接连接互联网,那么Maven就无法通过代理自动下载依赖包。

为了让Maven能够工作,你需要在Maven的配置文件 settings.xml里配置代理服务器的信息。

找到如下内容,把注释去掉,填写自己的代理信息,然后保存即可。

 1 <!-- proxies
 2    | This is a list of proxies which can be used on this machine to connect to the network.
 3    | Unless otherwise specified (by system property or command-line switch), the first proxy
 4    | specification in this list marked as active will be used.
 5    |-->
 6   <proxies>
 7     <!-- proxy
 8      | Specification for one proxy, to be used in connecting to the network.
 9      |
10     <proxy>
11       <id>optional</id>
12       <active>true</active>
13       <protocol>http</protocol>
14       <username>proxyuser</</username>
15       <password>proxypass</password>
16       <host>proxy.host.net</host>
17       <port>80</port>
18       <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
19     </proxy>
20     -->
21   </proxies>

提醒:Maven只是一个命令,当你调用它的时候,它会重新读取这个文件,所以没有重启Maven这一说法。

原文地址:https://www.cnblogs.com/yanyd/p/4262337.html