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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10564684/
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-09-10 21:03:09  来源:igfitidea点击:

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

eclipsemavenm2eclipseeclipse-wtp

提问by user810430

I have imported maven project in STS, when I run update update project I receive:

我在 STS 中导入了 Maven 项目,当我运行更新更新项目时,我收到:

"Updating Maven Project". Unsupported IClasspathEntry kind=4

Is there a workaround for this?

有解决方法吗?

回答by Marco

This issue has been fixed in m2e 1.5.0 which is available for Eclipse Kepler (4.3) and Luna (4.4)

此问题已在 m2e 1.5.0 中修复,可用于 Eclipse Kepler (4.3) 和 Luna (4.4)

Please see https://bugs.eclipse.org/bugs/show_bug.cgi?id=374332#c14

请参阅https://bugs.eclipse.org/bugs/show_bug.cgi?id=374332#c14

The problem is caused by the fact that STS (the Spring IDE/Eclipse), as well Eclipse and other Eclipse based IDE's, use the m2e(clipse) plugin but that eclipse:eclipse has been probably been run on the project. When m2e encounters a "var" .classpath entry, it throws this error.

问题是由于 STS(Spring IDE/Eclipse)以及 Eclipse 和其他基于 Eclipse 的 IDE 使用 m2e(clipse) 插件,但 eclipse:eclipse 可能已在项目上运行。当 m2e 遇到“var”.classpath 条目时,它会抛出此错误。

The update sites are specified at the following url:
http://eclipse.org/m2e/m2e-downloads.html

更新站点在以下 URL 中指定:http:
//eclipse.org/m2e/m2e-downloads.html

If you can't use m2e 1.5.0 for any reason, then :

如果您因任何原因无法使用 m2e 1.5.0,则:

  1. Disable the maven nature for the project (via the right-click menu)

  2. Run mvn eclipse:clean(while your project is openin STS/eclipse). Depending on the timing, you might need to do a refresh or two on the project before re-enabling the maven nature. You should be able to see that your project has lost it's Maven nature. (The eclipse:cleangoal just deletes the .project, .classpathand .settings/files/directories. You can also just remove those files (again while the project is open) instead of running mvn eclipse:clean.)

  3. Re-enable the maven nature.
    (Most of the time, this can be done by right-clicking on the project in question in the package explorer pane, and then choosing 'Configure'-> 'Convert to Maven Project')

  1. 禁用项目的 maven 特性(通过右键菜单)

  2. 运行mvn eclipse:clean(当您的项目在 STS/eclipse 中打开时)。根据时间安排,在重新启用 Maven 特性之前,您可能需要对项目进行一两次刷新。您应该能够看到您的项目已经失去了它的 Maven 性质。(eclipse:clean目标只是删除.project,.classpath.settings/文件/目录。您也可以只删除这些文件(再次在项目打开时)而不是运行mvn eclipse:clean。)

  3. 重新启用 Maven 特性。
    (大多数情况下,这可以通过在包资源管理器窗格中右键单击相关项目,然后选择“配置”->“转换为 Maven 项目”来完成)

回答by Sagar

  1. Right-click on your project, select Maven -> Remove Maven Nature.

  2. Open you terminal, go to your project folder and do mvn eclipse:clean

  3. Right click on your Project and select “Configure -> Convert into Maven Project”

  1. 右键单击您的项目,选择 Maven -> 删除 Maven Nature。

  2. 打开您的终端,转到您的项目文件夹并执行 mvn eclipse:clean

  3. 右键单击您的项目并选择“配置 -> 转换为 Maven 项目”

Now you got “Unsupported IClasspathEntry kind=4 Eclipse Scala” disappear.

现在,“Unsupported IClasspathEntry kind=4 Eclipse Scala”消失了。

回答by yannicuLar

Sometimes, even re-importing the Maven project will not work. Updating the project correctly in eclipse is not a deterministic process. The only 100% fail safe procedure I've found is:

有时,即使重新导入 Maven 项目也不起作用。在 eclipse 中正确更新项目不是一个确定性的过程。我发现的唯一 100% 故障安全程序是:

  1. Disable Maven Nature, run mvn eclipse:clean, restart, cross your fingers and Pray3 times.
  2. If this won't work, delete the project, run mvn eclipse:clean, re-import refresh, pray and use the force.
  3. If this still doesn't work, restart Eclipse, or even better your computer. While waiting for the reboot, you can make a random donationto fix your Karma. Repeat step 2 and don't forget to pray and control your anger. Anger leads to hate. Hate leads to suffering.
  4. Try all the other answers posted in this thread. You might need to try them all for 3 times at least before giving up.
  5. Formatyour Computer, re-install Eclipse and Maven. No need to pray anymore, all gods hate you anyway
  6. Delete your git project, burnthe physical drive that stored the remote repository, and write your project from scratch.
  7. Find a time machine, travel to the past and convince yourself to follow another, non-programming career or at least to avoid Java
  1. 禁用 Maven Nature,运行mvn eclipse:clean,重新启动,交叉手指并祈祷3 次。
  2. 如果这不起作用,请删除项目,运行mvn eclipse:clean,重新导入 refresh,祈祷并使用 force
  3. 如果这仍然不起作用,请重新启动 Eclipse,或者更好地启动您的计算机。在等待重启期间,您可以进行随机捐赠来修复您的 Karma。重复第 2 步,不要忘记祈祷并控制你的愤怒。愤怒导致仇恨。仇恨导致痛苦。
  4. 尝试在此线程中发布的所有其他答案。在放弃之前,您可能需要至少尝试 3 次。
  5. 格式化您的计算机,重新安装 Eclipse 和 Maven。不用再祈祷了,反正诸神都恨你
  6. 删除您的 git 项目,烧录存储远程存储库的物理驱动器,然后从头开始编写您的项目。
  7. 找到一台时光机,穿越到过去,说服自己从事另一个非编程的职业,或者至少避免使用 Java

回答by hicolour

  1. Make sure that the version of the m2e(clipse) plugin that you're running is at least 1.1.0

  2. Close maven project - right click "Close Project"

  3. Manualy remove all classpathentry with kind="var" in .classpath file
  4. Open project
  1. 确保您运行的 m2e(clipse) 插件的版本至少为 1.1.0

  2. 关闭 Maven 项目 - 右键单击​​“关闭项目”

  3. 手动删除 .classpath 文件中所有带有 kind="var" 的 classpathentry
  4. 打开项目

or

或者

  1. Remove maven project
  2. Manualy rmeove .classpath 4 Reimport project
  1. 删除 Maven 项目
  2. 手动 rmeove .classpath 4 重新导入项目

回答by Tam

Have you tried:

你有没有尝试过:

  1. If you have import project into the eclipse 4, please delete it.
  2. In maven consol, run: mvn eclipse:clean
  3. In Eclipse 4: File -> Import -> Maven -> Existing Maven Projects
  1. 如果您已将项目导入 eclipse 4,请将其删除。
  2. 在 maven consol 中,运行: mvn eclipse:clean
  3. 在 Eclipse 4 中:文件 -> 导入 -> Maven -> 现有 Maven 项目

回答by keiki

Seeing all other answers. I found for me a simpler way.

看到所有其他答案。我为我找到了一种更简单的方法。

I just removed all lines in the .classpath (editing with eclipse) containing a var and used maven -> update project without an error.

我刚刚删除了 .classpath(用 eclipse 编辑)中包含 var 的所有行,并使用了 maven -> 更新项目而没有错误。

回答by Andreis

This error is also thrown if the update command is used on a project instrumented for code coverage with Clover.

如果在使用 Clover 检测代码覆盖率的项目上使用更新命令,也会引发此错误。

To resolve in this scenario: Un-instrument the project folders you wish to update. Run the maven update then instrument for code coverage again.

在这种情况下解决:取消检测您要更新的项目文件夹。运行 Maven 更新,然后再次检测代码覆盖率。

回答by user1444080

I tried Marco's steps but no luck. Instead if you just get the latest m2e plugin from the link he provides and one by one right click on each project -> Maven -> Update Dependencies the error still pops up but the issue is resolved. That is to say the warnings disappear in the Markers view. I encountered this issue after importing some projects into SpringSource Tool Suite (STS). When I returned to my Eclipse Juno installation the warnings were displaying. Seeing that I had m2e 1.1 already installed I tried Marco's steps to no avail. Getting the latest version fixed it however.

我试过马可的步骤,但没有运气。相反,如果您只是从他提供的链接中获取最新的 m2e 插件,然后逐个右键单击每个项目 -> Maven -> 更新依赖项,错误仍然会弹出,但问题已解决。也就是说,警告在标记视图中消失。我在将一些项目导入 SpringSource Tool Suite (STS) 后遇到了这个问题。当我返回到我的 Eclipse Juno 安装时,显示了警告。看到我已经安装了 m2e 1.1,我尝试了 Marco 的步骤无济于事。然而,获得最新版本修复了它。

回答by user1069528

I couldn't get mvn eclipse:clean etc to work with Kepler.

我无法让 mvn eclipse:clean 等与开普勒一起工作。

However I changed creating and extending variables to just using external jars in my eclipse classpath. This was reflected in no var's in my .classpath.

但是,我将创建和扩展变量更改为仅在我的 eclipse 类路径中使用外部 jar。这反映在我的 .classpath 中没有 var 中。

This corrected the problem. I was able to do a Maven update.

这纠正了问题。我能够进行 Maven 更新。

回答by Fred Bricon

This issue (https://bugs.eclipse.org/394042) is fixed in m2e 1.5.0 which is available for Eclipse Kepler and Luna from this p2 repo :

这个问题 ( https://bugs.eclipse.org/394042) 在 m2e 1.5.0 中得到修复,它可用于 Eclipse Kepler 和 Luna 从这个 p2 repo :

http://download.eclipse.org/technology/m2e/releases/1.5

http://download.eclipse.org/technology/m2e/releases/1.5

If you also use m2e-wtp, you'll need to install m2e-wtp 1.1.0 as well :

如果您还使用 m2e-wtp,则还需要安装 m2e-wtp 1.1.0:

http://download.eclipse.org/m2e-wtp/releases/luna/1.1

http://download.eclipse.org/m2e-wtp/releases/luna/1.1