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>
/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>
Open your Eclipse and go to Window → Preferences
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.
10 comments
Write commentsThanks a lot, i tried everything but only this solution resolved my issue. Great job!!!!!!!!!
ReplyHelpful 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?
ReplyThanks, man!
ReplyThanks! This was exactly what I needed.
ReplyThank you so much. !
Replywhat is host here
ReplyWhat is host refer here. what exactly i ll put
ReplyGreat help! thanks!
ReplyProxy host is the URL of Proxy server. You should be able to get it from your organization's IT team.
ReplyThis worked for me, Thanks :)
ReplyEmoticonEmoticon