Java Eclipse - 导入现有的 Maven 项目会出现 Unsupported IClasspathEntry kind=4 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24972091/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 16:05:33  来源:igfitidea点击:

Eclipse - Importing an existing Maven project gives Unsupported IClasspathEntry kind=4 Error

javaeclipsemavenm2e

提问by Pat

I have an existing Maven project with correct pom.xml file. I am able to build the project from command line mvn install. However, when I import the project as existing Maven Project in eclipse, I get Unsupported IClasspathEntry kind=4error in eclipse.

我有一个带有正确 pom.xml 文件的现有 Maven 项目。我能够从命令行构建项目mvn install。但是,当我在 Eclipse 中将项目作为现有 Maven 项目导入时,在 Eclipse 中Unsupported IClasspathEntry kind=4出现错误。

Further, some of the project's properties are not correctly reflected after the import - E.g. it is a web project, but I do not see Deployed Resourcesunder the project structure. I can still see that little Mon the project icon indicating that it is a maven project.

此外,导入后无法正确反映项目的某些属性 - 例如,它是一个 Web 项目,但我Deployed Resources在项目结构下看不到。我仍然可以M在项目图标上看到一点,表明它是一个 Maven 项目。

I tried updating the project with Alt+F5and refreshed it with F5as well. Still the same error.

我尝试更新项目Alt+F5并刷新它F5。还是一样的错误。

I also tried the approach mentioned on this SO post

我也尝试了这个 SO 帖子中提到的方法

How to fix error "Updating Maven Project". Unsupported IClasspathEntry kind=4?

如何修复错误“更新 Maven 项目”。不支持的 IClasspathEntry kind=4?

  • i.e. Disable maven nature, eclipse:clean, re-enable maven nature. Still the same error when I enable maven nature.
  • 即禁用 Maven 自然,eclipse:clean,重新启用 Maven 自然。当我启用 Maven 自然时,仍然是同样的错误。

Eclipse also shows an error in my pom.xml, but mvn installworks fine from cmd line.

Eclipse 还在我的 pom.xml 中显示错误,但mvn install在 cmd 行中工作正常。

Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.5:copy-resources (default-cli)

I am not sure if these 2 errors are related or not.

我不确定这两个错误是否相关。

My setup:

我的设置:

  • Windows 7 Pro (64 bit)
  • JDK 1.6.0_31 (32 bit)
  • Eclipse Juno 4.2
  • Maven 3.0.5
  • m2e 1.4.0
  • Windows 7 专业版(64 位)
  • JDK 1.6.0_31(32 位)
  • Eclipse 朱诺 4.2
  • Maven 3.0.5
  • m2e 1.4.0

采纳答案by Pat

I finally managed to resolve the reported errors. This is what I followed:

我终于设法解决了报告的错误。这是我遵循的:

1) My eclipse was 64-bit version, but it was run using a 32-bit JVM. I changed eclipse.ini to use 64-bit JVM.

1) 我的 eclipse 是 64 位版本,但它是使用 32 位 JVM 运行的。我将 eclipse.ini 更改为使用 64 位 JVM。

2) Deleted the project from my workspace.

2)从我的工作区中删除了该项目。

3) Cleaned eclipse project files using mvn eclipse:clean. And created the project files again using mvn eclipse:eclipse

3) 使用mvn eclipse:clean. 并使用再次创建项目文件mvn eclipse:eclipse

4) Imported the project as General > Existing projectin eclipse

4)General > Existing project在eclipse中导入项目

5) Built the project

5)建设项目

This time, there were no errors reported for Unsupported IClasspathEntry kind=4. I hope, it helps others facing the same problem. Beware of Eclipse's 32-bit / 64-bit JVM. Prefer to use the same architecture as eclipse - i.e. use 64-bit JVM if your eclipse is 64-bit.

这一次,没有报告任何错误Unsupported IClasspathEntry kind=4。我希望,它可以帮助其他面临同样问题的人。当心 Eclipse 的 32 位 / 64 位 JVM。最好使用与 eclipse 相同的架构 - 即如果您的 eclipse 是 64 位,则使用 64 位 JVM。

回答by Arun Sharma

Right-click on your project, select Maven -> Remove Maven Nature. Open you terminal, go to your project folder and do “mvn eclipse:clean” Right click on your Project and select “Configure -> Convert into Maven Project”

右键单击您的项目,选择 Maven -> 删除 Maven Nature。打开您的终端,转到您的项目文件夹并执行“mvn eclipse:clean”右键单击您的项目并选择“配置 -> 转换为 Maven 项目”

回答by Marcin Erbel

For me the best sollution was to clear up the directory from hidden files (I don't know how this structure looks like on Windows OS).

对我来说,最好的解决方案是清除隐藏文件中的目录(我不知道这种结构在 Windows 操作系统上的样子)。

  1. Remove all hidden files from your project structure
  2. Be happy
  1. 从项目结构中删除所有隐藏文件
  2. 要开心