How to enable proxy setting in Maven
There are high chance your company is set up a firewall and force the developers to connect internet via using HTTP proxy. If you are using HTTP proxy, Maven may not able to download the dependency libraries outside. To bypass it, you have to enable the proxy setting in Maven configuration file “settings.xml“.
1. Maven configuration file
Find your Maven configuration file – e.g, {M2_HOME}/conf/settings.xml
2. Edit it “settings.xml”
Find the following pattern
<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</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> --> </proxies>
Comment out the proxy setting and fill in your proxy information.
<proxies> <proxy> <id>optional</id> <active>true</active> <protocol>http</protocol> <username>proxyuser</username> <password>proxypass</password> <host>proxy.yourcompany.com</host> <port>80</port> <nonProxyHosts>local.net|some.host.com</nonProxyHosts> </proxy> </proxies>
4. Saved it, Done.
Apache Maven is able to connect to Internet via proxy server now.
P.S No restart is required, how do you restart Maven
? Maven is just a command , when you call it, it will read this file again.



[...] Enable the proxy in Maven To use proxy server to connect internet, you have to configure the proxy setting in Maven. [...]
Thanks for this post, answers a bunch of questions I was having.
Thanks for the article. It looks good.
Please kindly write an article how to make use of maven in the projects.
Thanks
Hi,
Ya , writing a series of stuff regarding the Maven in Java development, let’s share it out