将 Maven 项目导入 Eclipse 时出错
Errors while importing Maven project into Eclipse
当我将从开源网站(例如 Apache,Github)下载的 Existing Maven Projects
导入到 Eclipse
时,发生了几个错误:( . 注意也就是说,所有的maven项目在Eclipse.
下都可以正确编译和测试
- 首先,将maven工程导入Eclipse后,工程图标上会有一个
red X
,但是工程没有报错。我发现 pom.xml
文件中存在 parent
节点。我删除了节点然后错误消失了,我想知道为什么因为maven项目中没有模块。下面的代码是我之前删除的节点
<parent>
<groupId> org.apache.commons </groupId>
<artifactId> commons-parent </artifactId>
<version> 38</version>
</parent>
接下来,在项目<a href="http://jaxen.org/" rel="nofollow noreferrer">jaxen</a>
中,这个项目的结构很奇怪。在项目中我刚刚找到 src/java/main
和 src/java/test
而不是 src/main/java 和 src/test/java ,即使它可以在 Eclipse 下正确 运行,我是否应该做任何其他配置?
此外,我在jaxen
、See 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)
出现以下错误
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
的初步用法。但是我还是不知道为什么。
呃...第二个问题需要我再努力解决。也许开发人员需要这些奇怪而奇怪的项目结构来实现另一个目标,如果有人能告诉我答案,我也将不胜感激,同样感谢 > <
当我将从开源网站(例如 Apache,Github)下载的 Existing Maven Projects
导入到 Eclipse
时,发生了几个错误:( . 注意也就是说,所有的maven项目在Eclipse.
- 首先,将maven工程导入Eclipse后,工程图标上会有一个
red X
,但是工程没有报错。我发现pom.xml
文件中存在parent
节点。我删除了节点然后错误消失了,我想知道为什么因为maven项目中没有模块。下面的代码是我之前删除的节点
<parent> <groupId> org.apache.commons </groupId> <artifactId> commons-parent </artifactId> <version> 38</version> </parent>
接下来,在项目
<a href="http://jaxen.org/" rel="nofollow noreferrer">jaxen</a>
中,这个项目的结构很奇怪。在项目中我刚刚找到src/java/main
和src/java/test
而不是 src/main/java 和 src/test/java ,即使它可以在 Eclipse 下正确 运行,我是否应该做任何其他配置?此外,我在
jaxen
、See 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)
出现以下错误 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
的初步用法。但是我还是不知道为什么。
呃...第二个问题需要我再努力解决。也许开发人员需要这些奇怪而奇怪的项目结构来实现另一个目标,如果有人能告诉我答案,我也将不胜感激,同样感谢 > <