Eclipse无法在公司代理后面更新Maven索引

时间:2015-09-30 09:23:01

标签: java eclipse proxy m2eclipse m2e

Eclipse Mars m2e插件无法在启动时下载存储库索引更新。我在公司防火墙后面运行Eclipse,但代理设置适用于“检查更新”,“eclipse marketplace”和eclipse的内置浏览器。

我尝试了以下内容:

  1. 删除缓存目录\eclipse\p2\org.eclipse.equinox.p2.repository\cache,然后刷新存储库。偏好 - >安装更新 - >可用的软件站点=>选择条目,然后单击“重新加载”

  2. 在eclipse.ini中将-Djava.net.preferIPv4Stack=true添加到-vmargs

  3. 编辑:$ HOME / .m2 / settings.xml中正确设置了代理配置 编辑:好像是一个错误。所以我用eclipse.org提出了一个错误请求。您可以查看here

    由于这个问题,eclipse无法搜索并添加来自maven存储库的依赖项。

    以下是.metadata / .log

    中的错误
    eclipse.buildId=4.5.0.I20150603-2000
    java.version=1.8.0_60
    java.vendor=Oracle Corporation
    BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_IN
    Framework arguments:  -product org.eclipse.epp.package.jee.product
    Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
    
    !ENTRY org.eclipse.m2e.logback.appender 4 0 2015-09-30 14:39:59.820
    !MESSAGE Unable to update index for central|https://repo.maven.apache.org/maven2
    !STACK 0
    java.net.ConnectException: Connection timed out: connect
            at java.net.TwoStacksPlainSocketImpl.socketConnect(Native Method)
            at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
            at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
            at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
            at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
            at java.net.Socket.connect(Socket.java:589)
            at com.squareup.okhttp.internal.Platform.connectSocket(Platform.java:107)
            at com.squareup.okhttp.Connection.connect(Connection.java:156)
            at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175)
            at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
            at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330)
            at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
            at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
            at com.squareup.okhttp.Call.getResponse(Call.java:271)
            at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
            at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
            at com.squareup.okhttp.Call.execute(Call.java:79)
            at io.takari.aether.okhttp.OkHttpAetherClient.execute(OkHttpAetherClient.java:154)
            at io.takari.aether.okhttp.OkHttpAetherClient.get(OkHttpAetherClient.java:100)
            at org.eclipse.m2e.core.internal.index.nexus.AetherClientResourceFetcher.retrieve(AetherClientResourceFetcher.java:79)
            at org.apache.maven.index.updater.AbstractResourceFetcher.retrieve(AbstractResourceFetcher.java:35)
            at org.apache.maven.index.updater.DefaultIndexUpdater.downloadIndexProperties(DefaultIndexUpdater.java:452)
            at org.apache.maven.index.updater.DefaultIndexUpdater.access$100(DefaultIndexUpdater.java:75)
            at org.apache.maven.index.updater.DefaultIndexUpdater$IndexAdaptor.setProperties(DefaultIndexUpdater.java:607)
            at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:788)
            at org.apache.maven.index.updater.DefaultIndexUpdater.fetchAndUpdateIndex(DefaultIndexUpdater.java:135)
            at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateRemoteIndex(NexusIndexManager.java:1127)
            at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager.updateIndex(NexusIndexManager.java:1084)
            at org.eclipse.m2e.core.internal.index.nexus.NexusIndexManager$1.run(NexusIndexManager.java:656)
            at org.eclipse.m2e.core.internal.index.nexus.IndexUpdaterJob.run(IndexUpdaterJob.java:72)
            at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
    

3 个答案:

答案 0 :(得分:1)

我找到了解决方案。这很简单。经过一些代码调查后,我发现了以下内容: 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

所以m2e扫描代理列表并试图通过协议找到正确的。如果你看一下中央网址:https://repo.maven.apache.org/maven2。它从“https”开始。

您的代理设置应如下(http的一个代理和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>

答案 1 :(得分:0)

虽然您已在eclispe中配置了代理,但您必须对maven执行相同的配置,进入settinggs.xml文件。这里有我的代理配置部分:

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

然后你必须在eclipse中确保使用已配置的settings.xml文件,window - &gt; preferences - maven - &gt; {{1} }。

希望它有所帮助。

答案 2 :(得分:0)

Maven使用自己的代理设置,在 .m2 / settings.xml 中定义。您可以在Eclipse的菜单中找到我的m2e插件使用的设置:Windows / Preferences / Maven / User Settings。请记住在编辑后点击“更新设置”按钮:

<!-- 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>