Simple configuration of mvn proxy in win

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.