While creating maven project, we many face issues during maven build, as maven tries to download dependency jars from a remote repository, and if there is a firewall and proxy set up, which may prevent maven from directly connecting to internet.

Latest eclipse IDE comes with maven build tool integrated and makes easier to create Maven projects using eclipse IDE. In this post, we will see how to set up proxy settings for maven on Eclipse IDE. Following are the steps to enable proxy settings.

  • Create a XML file name settings.xml and add the following content. Location of this file will be C:\Users\{User Name}\.m2\settings.xmlas eclipse will have default maven home set to C:\Users\{User Name}\.m2\ directory. copy your configuration file settings.xml to this directory. Set the proper proxy host, <username>, <password> and <nonProxyHosts> fields if required and save the file.
<proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
    </proxy>
  </proxies>
  • Navigate to Window > Preferences > Maven from eclipse toolbar. Under Maven preferences settings, select User Settings. Here, under User Settings, we need to add a settings.xml file location, which will contain the proxy settings details. Browse to the created settings.xml file and click on Update Settings button. Finally, click on OK. Now our Maven projects should use proxy settings to download the dependencies from the remote repository.

maven5

In this post we learned how to set proxy settings for Maven projects in eclipse IDE.

Note: Eclipse version: Eclipse Neon.

Also read: