Maven – Proxy setting

Maven helps you to manage all the dependencies in your java projects. Whenever you add a new dependency in the pom.xml. Maven will check if that dependency exists in the Maven Repository on internet. So in order to let Maven work, it should be allowed to access the internet without any problem.

So if your machine is located at a LAN behind a firewall and proxy is needed so as to access the internet, you have to configure the proxy for Maven as well.

Since this setting should be applied to all users, we should alter the M2_HOME/settings.xml which governs the global maven setting. The proxy is configured thought the following lines.

  <proxies>
    <!-- proxy setting -->
    <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>

Done =)

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.