Specify proxy in Maven

I’ve just started using Maven, and I suddenly stub into a problem where maybe everybody in big corporate have stubbed: connecting through a proxy.

Maven can connect to internet through an HTTP proxy that support basic authentication. In order to specify it, just create (or modify if exist) the file ~/.m2/settings.xml in the following way:

<settings>
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>put.here.the.proxy.address</host>
<port>3128</port>
<username>yourUserName</username>
<password>yourPassword</password>
<nonProxyHosts /> <!– useful for location to make bypassed by proxy –>
</proxy>
</proxies>
</settings>

That’s it! 🙂

Advertisements