Set Proxy for Maven in Eclipse

If your computer connects with Internet through a proxy server, Maven plugin of Eclipse will not update the project artifacts or Maven plugins. The system proxy settings or proxy settings of Eclipse are not detected by Maven plugin. This tutorial shows you the way to enable proxy for Maven in Eclipse. If you want to configure the proxy for the Apache Maven command line tool, follow the steps 1 and 2 only.

Step 1:
Copy and paste the following content in your favorite editor and save it as settings.xml in the given directory.
<?xml version="1.0" encoding="UTF-8"?>
<settings
 xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
 <pluginGroups/>
 <proxies>
  <!-- Proxy for HTTP -->
  <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</nonProxyHosts>
  </proxy>

  <!-- Proxy for HTTPS -->
  <proxy>
   <id>optional</id>
   <active>true</active>
   <protocol>https</protocol>
   <username>proxyuser</username>
   <password>proxypass</password>
   <host>proxy.host.net</host>
   <port>80</port>
   <nonProxyHosts>local.net</nonProxyHosts>
  </proxy>
 </proxies>

 <servers/>
 <mirrors/>
 <profiles/>
</settings>
Directory for Linux users:
/home/{username}/.m2/
Directory for Windows users:
C:\Users\{username}\.m2\

Step 2:
Modify the <proxies> tag according to your network proxy settings. Leave the username and password empty, if they are not appropriate for you.

For example if the proxy host is cache.javahelps.com and the port number is 3128, your proxy settings should look like this:
<proxies>
 <!-- Proxy for HTTP -->
 <proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <username></username>
  <password></password>
  <host>cache.javahelps.com</host>
  <port>3128</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
 </proxy>

 <!-- Proxy for HTTPS -->
 <proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>https</protocol>
  <username></username>
  <password></password>
  <host>cache.javahelps.com</host>
  <port>3128</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
 </proxy>
</proxies>

Step 3:
Open your Eclipse and go to Window → Preferences

Step 4:
In the appeared Preferences dialog, expand the Maven → User Settings


Step 5:
Click on the Browse button of User Settings, and select the settings.xml.


Step 6:
Click on the "Update Settings" button to update the settings. If any confirmation dialog appeared, just click Yes.

Step 7:
Click Apply and OK on the Preferences dialog.

Now your Maven plugin is ready to connect through your proxy server.
Previous
Next Post »

3 comments

Write comments
veeranarayana jami
AUTHOR
December 7, 2017 at 5:16 AM delete

Thanks a lot, i tried everything but only this solution resolved my issue. Great job!!!!!!!!!

Reply
avatar
Netra
AUTHOR
December 18, 2017 at 5:03 PM delete

Helpful article. Thanks. IN setting.xml is twice. both values are "optional". I am getting warning for the same in command line. Can i have diffent names? What is the significane of this id?

Reply
avatar
Régis Siminski
AUTHOR
January 10, 2018 at 4:38 AM delete

Thanks, man!

Reply
avatar

Contact Form

Name

Email *

Message *