启用 Maven 依赖管理会禁用 Eclipse 中的重构菜单项

发布于 2024-09-13 00:57:51 字数 4924 浏览 14 评论 0原文

有没有人注意到,在 Eclipse 中为项目启用 Maven 依赖关系管理后,Java 编辑器上下文菜单上的重构项消失了?

有解决办法吗?补丁还是升级?还是拼凑?

更多信息: 需要进一步断言项目/包资源管理器上的上下文菜单不受影响。重构项仍然存在。

受影响的是 Java 编辑器 - 重构项从上下文菜单中消失。

错误日志

Plug-in 'org.maven.ide.eclipse.refactoring' contributed an invalid Menu Extension (Path: 'org.eclipse.jdt.ui.refactoring.menu' is invalid): org.maven.ide.eclipse.editor.RenameProjectAction

An exception stack trace is not available.

Session data:
eclipse.buildId=2.3.3.201007151000-M2
java.version=1.6.0_18
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product com.springsource.sts.ide

尝试启用 GWT 时失败操作的错误日志

Failed to update action com.google.gwt.eclipse.core.actions.AddResourcesToClientBundleAction

Exception trace:
ava.lang.ClassNotFoundException: com.google.gdt.eclipse.platform.jdt.model.PlatformJavaModelUtilities$IAnnotationNotAvailableException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at com.google.gwt.eclipse.core.clientbundle.ClientBundleResource.isProbableClientBundleResource(ClientBundleResource.java:105)
at com.google.gwt.eclipse.core.clientbundle.ui.AddResourcesToClientBundleAction.selectionChanged(AddResourcesToClientBundleAction.java:203)
at org.eclipse.ui.internal.PluginAction.refreshEnablement(PluginAction.java:206)
at org.eclipse.ui.internal.PluginAction.selectionChanged(PluginAction.java:277)
at org.eclipse.ui.internal.ObjectActionContributor$1.run(ObjectActionContributor.java:157)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.ObjectActionContributor.contributeObjectActions(ObjectActionContributor.java:160)
at org.eclipse.ui.internal.ObjectActionContributorManager.contributeObjectActions(ObjectActionContributorManager.java:97)
at org.eclipse.ui.internal.PopupMenuExtender.addObjectActions(PopupMenuExtender.java:262)
at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:339)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:338)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:465)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:491)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:241)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1263)
at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:199)
at org.eclipse.swt.widgets.Display.runPopups(Display.java:3593)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3168)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Does anyone notice that after enabling Maven dependency management in Eclipse for a project, the refactor item on the context menu of Java editor disappears for that project?

Is there a solution to that? A patch or upgrade? Or a kludge?

Further Info:
Need to further assert that the context menu on project/package explorer is unaffected. The refactor item is still there.

It is the Java Editor that is affected - where the refactor item disappeared from the context menu.

Error Log:

Plug-in 'org.maven.ide.eclipse.refactoring' contributed an invalid Menu Extension (Path: 'org.eclipse.jdt.ui.refactoring.menu' is invalid): org.maven.ide.eclipse.editor.RenameProjectAction

An exception stack trace is not available.

Session data:
eclipse.buildId=2.3.3.201007151000-M2
java.version=1.6.0_18
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  -product com.springsource.sts.ide
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product com.springsource.sts.ide

error log of failed action when attempting to enable GWT:

Failed to update action com.google.gwt.eclipse.core.actions.AddResourcesToClientBundleAction

Exception trace:
ava.lang.ClassNotFoundException: com.google.gdt.eclipse.platform.jdt.model.PlatformJavaModelUtilities$IAnnotationNotAvailableException
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at com.google.gwt.eclipse.core.clientbundle.ClientBundleResource.isProbableClientBundleResource(ClientBundleResource.java:105)
at com.google.gwt.eclipse.core.clientbundle.ui.AddResourcesToClientBundleAction.selectionChanged(AddResourcesToClientBundleAction.java:203)
at org.eclipse.ui.internal.PluginAction.refreshEnablement(PluginAction.java:206)
at org.eclipse.ui.internal.PluginAction.selectionChanged(PluginAction.java:277)
at org.eclipse.ui.internal.ObjectActionContributor$1.run(ObjectActionContributor.java:157)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.ObjectActionContributor.contributeObjectActions(ObjectActionContributor.java:160)
at org.eclipse.ui.internal.ObjectActionContributorManager.contributeObjectActions(ObjectActionContributorManager.java:97)
at org.eclipse.ui.internal.PopupMenuExtender.addObjectActions(PopupMenuExtender.java:262)
at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:339)
at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:338)
at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:469)
at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:465)
at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:491)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:241)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1263)
at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:199)
at org.eclipse.swt.widgets.Display.runPopups(Display.java:3593)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3168)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

追风人 2024-09-20 00:57:51

这不是我所经历的。下面的屏幕截图显示了Maven项目上下文菜单中的重构条目:

替代文本 http://a.yfrog.com/img842/3705/screenshot008b.png

以及上下文菜单中的重构条目此 Maven 项目 的 Java 资源(在 Java 编辑器中右键单击时也会得到):

alt text http://a.yfrog.com/img201/9843/screenshot009n.png

但请注意,我没有像你一样使用 Eclipse 和 m2eclipse,我在外部创建 Maven 项目Eclipse 和导入...>现有的 Maven 项目(我不喜欢向导)。但不确定这会有所不同。

This is not what I'm experiencing. Below a screenshot showing the Refactoring entry in the contextual menu of a Maven Project:

alt text http://a.yfrog.com/img842/3705/screenshot008b.png

And the Refactoring entry in the contextual menu of a Java Resource of this Maven Project (that I also get when right clicking in the Java editor):

alt text http://a.yfrog.com/img201/9843/screenshot009n.png

But note that I'm not using Eclipse and m2eclipse like you are, I create Maven projects outside Eclipse and Import... > Existing Maven Projects (I'm not fan of wizards). Not sure this makes a difference though.

假情假意假温柔 2024-09-20 00:57:51

我发现很难回答我自己的问题,但是......

答案是:要在 Eclipse 中获取 Maven 托管项目,请勿使用 m2eclipse 菜单创建或启用 Maven 依赖项托管项目。那些 m2eclipse 菜单项已损坏。

您必须在 shell/命令窗口中使用 mvn archetype:generate 命令来创建该项目。

mvn archetype:generate \
 -DgroupId=holy.moly \
 -DartifactId=holymoly \
 -Dpackage=holy.moly \
 -Dversion=1.0-VOILA

然后在 Eclipse 中使用 import:maven:existing maven project 菜单项将该项目导入到 Eclipse 中。

一些产品提供了有关如何从 shell/命令窗口生成 Maven 项目,然后导入到 Eclipse 的各自建议。例如,Vaadin 的:

mvn archetype:generate \
-DarchetypeGroupId=com.vaadin \
-DarchetypeArtifactId=vaadin-archetype-clean \
-DarchetypeVersion=LATEST \
-DgroupId=holy.moly  \
-DartifactId=holymoly \
-Dversion=1.0 \
-Dpackaging=war

但是,尝试启用 GWT 会导致错误。

使用 IAM
我正在编辑说我从我的 helios 设置之一卸载了 m2eclipse 并安装了 IAM。 IAM 没有导致任何菜单项消失。我能够启用 GWT。

重构项仍在菜单上,但尝试在 Java 编辑器上重构或在项目资源管理器上重命名文件将失败:

java.lang.NullPointerException
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run_aroundBody1$advice(RenameJavaElementAction.java:35)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:1)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.doRun(RenameJavaElementAction.java:148)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:129)
    at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:115)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

I find it hard to swallow answering my own question, but ...

The answer is: To obtain a maven managed project in Eclipse, do not use m2eclipse menu to create or enable as Maven dependency managed project. Those m2eclipse menu items are are broken.

You have to use mvn archetype:generate commands at the shell/command window to create that project.

mvn archetype:generate \
 -DgroupId=holy.moly \
 -DartifactId=holymoly \
 -Dpackage=holy.moly \
 -Dversion=1.0-VOILA

And then in Eclipse use the import:maven:existing maven project menu item to import that project into Eclipse.

Some products give their respective advisory on how to generate a maven project from shell/command window, and then to be imported into Eclipse. For example, Vaadin's:

mvn archetype:generate \
-DarchetypeGroupId=com.vaadin \
-DarchetypeArtifactId=vaadin-archetype-clean \
-DarchetypeVersion=LATEST \
-DgroupId=holy.moly  \
-DartifactId=holymoly \
-Dversion=1.0 \
-Dpackaging=war

However, attempting to enable GWT would cause error.

Using IAM:
I am editing to say that I uninstalled m2eclipse from one of my helios setup and installed IAM. IAM did not cause any menu items to disappear. I was able to enable GWT.

The refactor item was still on the menu but attempting to refactor on Java Editor or rename a file on Project explorer would fail:

java.lang.NullPointerException
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run_aroundBody1$advice(RenameJavaElementAction.java:35)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:1)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.doRun(RenameJavaElementAction.java:148)
    at org.eclipse.jdt.internal.ui.refactoring.actions.RenameJavaElementAction.run(RenameJavaElementAction.java:129)
    at org.eclipse.jdt.ui.actions.RenameAction.run(RenameAction.java:115)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:278)
    at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:250)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3552)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3171)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:616)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文