将Maven项目导入Eclipse

时间:2017-01-11 10:02:27

标签: eclipse maven import pom.xml

当我将从开源网站(例如Apache,Github)下载的Existing Maven Projects导入Eclipse时,发生了几个错误:(。请注意,所有maven项目都可以正确编译并在Eclipse下进行测试

  • 首先,在将maven项目导入Eclipse后,项目图标上会有red X,但项目中没有错误。我发现parent文件中存在pom.xml个节点。我删除了节点然后错误消失了,我想知道为什么因为maven项目中没有模块。以下代码是我之前删除的节点。
<parent>
    <groupId> org.apache.commons </groupId>
    <artifactId> commons-parent </artifactId>
    <version> 38</version>
  </parent>
  • 接下来,在项目jaxen中,此项目的结构很奇怪。在我刚刚找到src/java/mainsrc/java/test而不是 src / main / java src / test / java 的项目中,是否还有其他配置我应该这样做,即使它可以在Eclipse下正确运行吗?

  • 此外,我还在jaxenSee this picture的代码来源中发现了错误,错误信息部分给出如下,寻求您的帮助并提前感谢:)

Failure to transfer xerces:xmlParserAPIs:jar:2.6.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xerces:xmlParserAPIs:jar:2.6.2 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

org.eclipse.aether.transfer.ArtifactTransferException: Failure to transfer xerces:xmlParserAPIs:jar:2.6.2 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact xerces:xmlParserAPIs:jar:2.6.2 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:238)
    at org.eclipse.aether.internal.impl.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:206)

2 个答案:

答案 0 :(得分:0)

以下错误 org.eclipse.aether.transfer.ArtifactTransferException:无法传输xerces:来自https://repo.maven.apache.org/maven2的xmlParserAPIs:jar:2.6.2被缓存在本地存储库中,在中心的更新间隔过去或更新之前,不会重新尝试解析被迫。原始错误:无法传输工件xerces:xmlParserAPIs:jar:2.6.2 from / to central(https://repo.maven.apache.org/maven2):操作已取消 将由第2步修复。

试试这个,如果1不起作用,试试2:

1)首先更新项目,Alt-F5

2)然后转到您的仓库并吹走该依赖项的目录,该目录应位于目录HOME_DIRECTORY / .m2 / repo / xerces / xmlParserAPIs / 2.6.2中 然后再做一次Alt-F5。

3)如果失败,请从命令行尝试mvn clean install -U。

答案 1 :(得分:0)

虽然我接受了Essex Boy的回答,但我想说另一个链接Error on Importing existing Maven project to eclipse与我的第三个问题类似。也许从本地maven存储库清理相应的jar是一个很好的解决方案。

至于我的第一个问题 http://maven.apache.org/guides/introduction/introduction-to-the-pom.html告诉我们parent的初步用法。但我仍然不知道为什么。

呃...... 第二个问题需要我的另一个努力来解决它。也许开发人员需要这些奇怪的和奇怪的项目结构为另一个目标,如果有人可以告诉我答案,我也会很感激,谢谢所有相同&gt; &LT;

相关问题