Eclipse fails to update Maven index while behind company proxy

爷,独闯天下 提交于 2019-12-08 13:05:29

I've found solution. It's quite simple. After some code investigation I've found following thing: https://github.com/eclipse/m2e-core/blob/releases/1.6/1.6.2.20150902-0002/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/embedder/MavenImpl.java#L1226

So m2e scans proxy list and trying to find correct by protocol. If you look at central url: https://repo.maven.apache.org/maven2. It's starts from "https".

Your proxy settings should looks like that (one proxy for http and second for https):

<proxies>
  <proxy>
    <active>true</active>
    <protocol>http</protocol>
    <host>myproxy.company.com</host>
    <port>8080</port>
  </proxy>
    <proxy>
      <active>true</active>
      <protocol>https</protocol>
      <host>myproxy.company.com</host>
      <port>8080</port>
    </proxy>
</proxies>

Although you have configured proxy in eclispe, you have to do the same config for maven, into settinggs.xml file. Here you have my proxy configuration section:

<proxies>
  <proxy>
    <active>true</active>
    <protocol>http</protocol>
    <host>myproxy.company.com</host>
    <port>8080</port>
  </proxy>
</proxies>

Then you have to ensure in eclipse that you are using the configured settings.xml file, in window->preferences-maven->user settings.

Hope it helps.

Maven uses its own proxy settings, defined in .m2/settings.xml. You can find the settings used my m2e plugin in Eclipse's menu: Windows / Preferences / Maven / User Settings. Remember to hit the Update Settings -button after editing:

<!-- proxies
 | This is a list of proxies which can be used on this machine to connect to the network.
 | Unless otherwise specified (by system property or command-line switch), the first proxy
 | specification in this list marked as active will be used.
 |-->
<proxies>
  <!-- proxy
   | Specification for one proxy, to be used in connecting to the network.
   |
  <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|some.host.com</nonProxyHosts>
  </proxy>
  -->
</proxies>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!