eclipse JAVA

Enable Proxy Setting For Maven In Eclipse IDE

In this article, we will learn how to enable the proxy details for Maven in the Eclipse IDE.

While creating the maven project, we may face issues during maven build, as maven tries to download dependency jars from a remote repository. Also, firewall or internet proxy configuration may prevent maven from directly connecting to the internet. The latest Eclipse IDE comes with a maven build tool integrated and makes it 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.

Eclipse version: Eclipse Neon.

Create the maven proxy settings file

The first step is to create a configuration file and override the default maven configurations.

Create an XML file with the name settings.xml and add the following content. 

The location of this file will be under the directory C:\Users\{User Name}\.m2\settings.xml, as the eclipse IDe will have default maven home set to C:\Users\{User Name}\.m2\ directory.

Copy your configuration file settings.xml that we have created earlier 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 the Window > Preferences > Maven option from the eclipse toolbar. Under Maven preferences settings, select User Settings.

Here, under User Settings, we need to add our settings.xml file’s location, which contains the details of the proxy setting.

Browse to the created settings.xml file and click on the Update Settings button.

Finally, click on the OK button. Now our Maven projects should use proxy settings to download the dependencies from the remote repository.

proxy setting maven eclipse

Conclusion

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