简体   繁体   English

m2eclipse无法从中央仓库更新索引

[英]m2eclipse cannot update index from central repo

I have just downloaded and installed M2Eclipse, but it fails to update the index of the central repo. 我刚刚下载并安装了M2Eclipse,但它无法更新中央仓库的索引。 At the same time, Maven itself is able to download artifacts from the repo (via command line). 同时,Maven本身可以从repo下载工件(通过命令行)。

I had the settings.xml file in maven/conf , and I copied it to .m2/ directory, but it didn't help. 我在maven/confsettings.xml文件,并将其复制到.m2/目录,但它没有帮助。

I have proxy, but proxy settings are given in settings.xml - commands from command line work fine, but not in Eclipse. 我有代理,但代理服务器设置在给定settings.xml -从命令行做工精细命令,但不能在Eclipse中。 In Eclipse it gives me this: 在Eclipse中它给了我这个:

Unable to update index for central|http://repo1.maven.org/maven2

UPDATE: 更新:

This is what I get when I try to create a new Maven Project: 这是我尝试创建一个新的Maven项目时得到的:

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-quickstart:RELEASE from any of the configured repositories.
Could not resolve artifact
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Documents and Settings\user\.m2\repository)
Failed to resolve version for org.apache.maven.archetypes:maven-archetype-quickstart:pom:RELEASE: Could not find metadata org.apache.maven.archetypes:maven-archetype-quickstart/maven-metadata.xml in local (C:\Documents and Settings\user\.m2\repository)

Just add this mirror to the settings.xml : 只需将此镜像添加到settings.xml

<mirror>
  <id>ibiblio.org</id>
  <url>http://mirrors.ibiblio.org/maven2</url>
  <mirrorOf>central</mirrorOf>
</mirror>

Please check your m2eclipse installations configuration, have you pointed it to the correct settings.xml file ? 请检查您的m2eclipse安装配置,您是否已将其指向正确的settings.xml文件?

在此输入图像描述

if you are behind a proxy do your proxy settings on your usersettings file as below 如果您在代理服务器后面,请在您的usersettings文件上执行代理设置,如下所示

<proxies>
    <proxy>
        <id>myId</id>
        <active>true</active>
        <protocol>http</protocol>
        <username>MyUser</username>
        <password>MyPassword</password>
        <host>my.proxy.host</host>
        <port>myproxyport</port>
        <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
</proxies>

Changes in both global and user specific settings/xml are needed in order custom maven installation to work inside eclipse. 需要在全局和用户特定设置/ xml中进行更改才能使自定义maven安装在eclipse中工作。 I don't know why but it helped for me. 我不知道为什么,但它对我有帮助。

If the problem is not about connection/proxy, try a more drastic way: delete the whole .metadata folder. 如果问题不是关于连接/代理,请尝试更激烈的方法:删除整个.metadata文件夹。 Later import projects from their place or checkout them from the svn(if you use some). 稍后从他们的地方导入项目或从svn签出(如果你使用的话)。 This is not much more complicated, but it helped. 这并不复杂,但它有所帮助。 the problem is that we don't really know, what metadata are broken, so the natural next step is to delete all of them. 问题是我们并不真正知道什么元数据被破坏,所以下一步自然就是删除所有元数据。 I think, it is the deepest possible cleaning before reinstallation of Eclipse + plugins. 我认为,在重新安装Eclipse +插件之前,这是最彻底的清理。

为了避免必须在2个地方更改设置,只需依赖全局设置,这很有效:

ln -s /etc/maven2/settings.xml ~/.m2/settings.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM