67

I am using springsource tool suite 2.7.2, based on Eclipse 3.7. The Maven plugin comes now out of the box with Eclipse which is great, and this problem occurred even with previous version of Eclipse.

So here is my issue:

I have set the proxy information in my settings.xml file, and on the command line Maven works just fine. I have also set the same proxy details in the Eclipse configuration itself, and I know that it is correct as well as the updates work with it and not without.

Of course, the Maven plugin in my Eclipse installation is set to use the proper settings.xml file.

But maven from within eclipse just doesn't use the proxy settings from either of those places, which is very annoying every time I change the pom file. Does anyone have a solution for this issue ?

settings.xml

Here is my settings.xml file:

<?xml version="1.0" encoding="UTF-8"?>
  <settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <profiles>
    <profile>
      <id>general</id>
      <repositories>
        <repository>
          <snapshots><enabled>false</enabled></snapshots>
          <id>ibiblio</id>
          <name>Maven ibiblio</name>
          <url>http://www.ibiblio.org/maven2</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>ibiblio2</id>
          <name>Maven ibiblio2</name>
          <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>maven</id>
          <name>Maven sunsite</name>
          <url>http://repo1.maven.org/maven2/</url>
        </repository>

        <repository>
          <snapshots><enabled>true</enabled></snapshots>
          <id>jboss</id>
          <name>Maven jboss</name>
          <url>http://repository.jboss.org/maven2/</url>
        </repository>
      </repositories>
    </profile>
  </profiles>

  <activeProfiles>
    <activeProfile>general</activeProfile>
  </activeProfiles>

  <proxies>
    <proxy>
      <id>proxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>myproxyserver</host>
      <port>80</port>
      <username>myusername</username>
      <password>mypassword</password>
    </proxy>
  </proxies>
</settings>
Community
  • 1
  • 1
TheYann
  • 1,367
  • 2
  • 12
  • 13
  • Do you use embedded maven installation? – yozh Oct 12 '11 at 09:16
  • yes I do, I didn't install anything special for maven support so it's all out of the box. – TheYann Oct 12 '11 at 09:19
  • M2E proxy usage works for me. I just checked my proxy log to confirm it. Please post your settings.xml, maybe the command line is picking setting in another way (Linux might allow http_proxy envvar for example). – Darryl Miles Oct 13 '11 at 20:27
  • I added my settings.xml content now. Unfortunately I don't have access to the proxy logs as it's managed by my company and totally unreachable for me :( But as far as I know this is ok, as with the command line it works just fine ! – TheYann Oct 14 '11 at 13:00

3 Answers3

114

Maven plugin uses a settings file where the configuration can be set. Its path is available in Eclipse at Window|Preferences|Maven|User Settings. If the file doesn't exist, create it and put on something like this:

<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">
  <localRepository/>
  <interactiveMode/>
  <usePluginRegistry/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>192.168.1.100</host>
      <port>6666</port>
      <username></username>
      <password></password>
      <nonProxyHosts>localhost|127.0.0.1</nonProxyHosts>
    </proxy>
  </proxies>
  <profiles/>
  <activeProfiles/>
</settings>

After editing the file, it's just a matter of clicking on Update Settings button and it's done. I've just done it and it worked :)

Trinimon
  • 13,839
  • 9
  • 44
  • 60
Alfabravo
  • 7,493
  • 6
  • 46
  • 82
  • 18
    After you make the changes described above you may still get an error if you try to update your project in Eclipse. You need to force the update: Right-click on your project (project/package explorer) -> Maven -> Update project -> Check "Force Update of Snapshots/Releases" box, then Click OK. – Sam Oct 07 '13 at 17:53
  • 1
    working.. thanks for providing a sample settings.xml – Vishnudev K May 22 '14 at 07:51
  • sample and force update, using both it works for me! thank you both of you! – Jugal Panchal May 29 '15 at 06:51
  • 1
    Check "Force Update of Snapshots/Releases" box is absolutely necessary. Thank you! – xli Feb 22 '16 at 17:10
  • HEY GUYS ,Please look here if you can't fix http://stackoverflow.com/a/25912472/5478948 – java.nazif Jan 02 '17 at 13:59
  • @skynafo that's a good catch in that answer. Isn't it a different problem, tho? – Alfabravo Jan 02 '17 at 15:07
  • 1
    According to the documentation exceptions have to be delimited by `|` and not `,` (see https://maven.apache.org/guides/mini/guide-proxies.html) – Trinimon Apr 20 '17 at 11:31
  • @Trinimon thanks! This was quite some time ago and I can't remember if it changed. – Alfabravo Apr 20 '17 at 13:21
35
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

     <proxies>
       <proxy>
          <active>true</active>
          <protocol>http</protocol>
          <host>proxy.somewhere.com</host>
          <port>8080</port>
          <username>proxyuser</username>
          <password>somepassword</password>
          <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
        </proxy>
      </proxies>

    </settings>

Window > Preferences > Maven > User Settings

enter image description here

Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125
4

Eclipse by default does not know about your external Maven installation and uses the embedded one. Therefore in order for Eclipse to use your global settings you need to set it in menu SettingsMavenInstallations.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yozh
  • 1,213
  • 2
  • 10
  • 18
  • 11
    actually that is incorrect. in Settings > Maven > User Settings you can set the path to the settings.xml file which by default points to the right place. Also I have tried using both the embedded or an external version of maven but still no luck. – TheYann Oct 12 '11 at 10:55