将 Maven 项目导入 Eclipse 时出错

Errors while importing Maven project into Eclipse

当我将从开源网站(例如 Apache,Github)下载的 Existing Maven Projects 导入到 Eclipse 时,发生了几个错误:( . 注意也就是说,所有的maven项目在Eclipse.

下都可以正确编译和测试
<parent>
    <groupId> org.apache.commons </groupId>
    <artifactId> commons-parent </artifactId>
    <version> 38</version>
  </parent>
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)

出现以下错误 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): 操作被取消 将在步骤 2 中修复。

试试这个,如果 1 不行试试 2:

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

2) 然后转到你的 repo 并删除该依赖项的目录,该目录应该在目录 HOME_DIRECTORY/.m2/repo/xerces/xmlParserAPIs/2.6.2 中 然后再次执行 Alt-F5。

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

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

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

呃...第二个问题需要我再努力解决。也许开发人员需要这些奇怪而奇怪的项目结构来实现另一个目标,如果有人能告诉我答案,我也将不胜感激,同样感谢 > <