Enable Proxy Setting

In this section, you will learn to enable proxy setting for Maven using setting.xml file .

Enable Proxy Setting

Enable Proxy Setting

In this section, you will learn to enable proxy setting for Maven using setting.xml file .

Need

Almost every organization installs a firewall  and every user connects to the internet through HTTP proxy. If Http proxy is employed by your organization, Maven will not be capable of downloading dependencies from outside. To bypass the Http proxy, you need to configure the proxy setting in Maven's configuration file(settings.xml).

Where to find setting.xml ?

You can find settings.xml inside {M2_HOME}\conf\settings.xml, ex.:-C:\apache-maven-2.2.1\conf\settings.xml.

Alternate way to enable  proxy settings

You can also enable proxy settings by creating setting.xml inside default local repository of Maven( .m2 directory) as

C:\Documents and Settings\<login-username>\.m2\settings.xml .

The configuartion is same in both condition.

Where to find .m2 directory ?

If you are using Windows XP, this should be under :

<root>\Documents and Settings\<login-username>\.m2

Ex.:- C:\Documents and Settings\roseindia\.m2

If you are using Window 7 , you can find it under :

<root>\Users\<login-username>\.m2

Ex. :- C:\Users\roseindia\.m2

If you are using Unix/Mac OS X, you can find it under :

~/.m2

How to enable  proxy settings in  setting.xml file(configuration)?

To bypass the Http proxy, you need to enable the proxy setting in  setting.xml file as follows :

<settings xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
	<proxy>
		<id>optional</id>
		<active>true</active>
		<protocol>http</protocol>
		<username>proxyuser</username>
		<password>proxypass</password>
		<host>proxy.yourcompany.com | ip-address</host>
		<port>80 | port-number</port>
		<nonProxyHosts>local.net | some.host.com</nonProxyHosts>
	</proxy>
</proxies>

</settings>