The solution is simple. You only need to modify the conf/settings. xml file in the maven path.
The default proxy configuration (apache-maven-2.2.1) is as follows:
<! -- Proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| Specification in this list marked as active will be used.
| -->
<Proxies>
<! -- Proxy
| Specification for one proxy, to be used in connecting to the network.
|
<Proxy>
<Id> optional </id>
<Active> true </active>
<Protocol> http </protocol>
<Username> proxyuser </username>
<Password> proxypass </password>
<Host> proxy.host.net <Port> 80 </port>
<NonProxyHosts> local.net | some.host.com </nonProxyHosts>
</Proxy>
-->
</Proxies>
The modification should be simple. Remember to remove the comment!
Complete example
1. Find the file {M2_HOME}/conf/settings. xml in the Maven configuration file and write the configuration of your proxy server. Note: {M2_HOME }=> D: \ software \ yiibai.com \ apache-maven
{M2_HOME}/conf/settings. xml
<! -- Proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| Specification in this list marked as active will be used.
| -->
<Proxies>
<! -- Proxy
| Specification for one proxy, to be used in connecting to the network.
|
<Proxy>
<Id> optional </id>
<Active> true </active>
<Protocol> http </protocol>
<Username> proxyuser </username>
<Password> proxypass </password>
<Host> proxy.host.net <Port> 80 </port>
<NonProxyHosts> local.net | some.host.com </nonProxyHosts>
</Proxy>
-->
</Proxies>
Deselect the comment proxy option and enter the details of your proxy server.
<! -- Proxies
| This is a list of proxies which can be used on this machine to connect to the network.
| Unless otherwise specified (by system property or command-line switch), the first proxy
| Specification in this list marked as active will be used.
| -->
<Proxies>
<Proxy>
<Id> optional </id>
<Active> true </active>
<Protocol> http </protocol>
<Username> yiibai </username>
<Password> password </password>
<Host> proxy.yiibai.com <Port> 8888 </port>
<NonProxyHosts> local.net | some.host.com </nonProxyHosts>
</Proxy>
</Proxies>
2. After saving the file, Apache Maven should be able to connect to the Internet immediately through the proxy server.
Note: restarting is not required. Maven is just a command. When you call it, it will read the file again.