最近在为eclipse配置maven和scala插件,昨天捣鼓了一天,今天终于把问题解决,其实也不是解决问题,只是重新启动新的eclipse,然后插件全部都重新装,由于之前装的插件顺序也比较混乱,只是要用什么,就装了一下的,导致eclipse崩溃。
eclipse 3.7(indigo),由于3.7版本是最新的,所以插件有可能不稳定,会导致一些意想不到的错误。
1.安装maven插件
安装插件有好几种方法,一种是在help->Eclipse marketplace 查找m2e,另一种是在help->Install New Software,地址为:http://download.eclipse.org/technology/m2e/releases/
说明:网上也有人说因为eclipse是最新版,可能你下的m2e插件不稳定,导致在Install New SoftWare的时候安装不了。查看jboss的官方博客,已经有新版的m2e插件出现在marketplace中。
一般来说,都是调用外部的settings.xml文件,这个时候就需要在window->preferences->maven->user settings选择你本地的文件。
2.安装scala插件
打开http://scala-ide.org/download/current.html,你会看到适合eclipse各种版本的scala插件下载地址,适合indigo的地址是:http://download.scala-ide.org/releases-29/stable/site
3.安装jetty插件
maven项目比较推崇jetty服务器,在eclipse里用命令运行,平时能查看源码,但是debug的时候,会导致找不到maven 仓库里的源码(不知道大家有没有遇到过类似的问题)。
解决办法:安装jetty插件,在help->Eclipse Marketplace 输入jetty,安装下,之后debug就能解决这个问题的。这样会有另一个问题的发生,因为在pom里配置jetty插件需要配置系统变量如下:
<systemProperties>
<systemProperty>
<name>CONFIG_DIR_PATH</name>
<value>${basedir}/config</value>
</systemProperty>
</systemProperties>
这样用命令行:mvn jetty:run 就可以读到系统变量,但是用eclipse jetty插件就会导致找不到CONFIG_DIR_PATH。
参考http://stackoverflow.com/questions/3895047/jetty-set-system-property,http://docs.codehaus.org/display/JETTY/jetty.xml,http://blog.csdn.net/CrazyCoder2010
在WEB-INF下建一个名字为jetty-web.xml或者web-jetty.xml,格式如下:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
"http://jetty.mortbay.org/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call class="java.lang.System" name="setProperties">
<Arg>
<New class="java.util.Properties">
<Call name="putAll">
<Arg>
<Call class="java.lang.System" name="getProperties" />
</Arg>
</Call>
<Call name="setProperty">
<Arg>CONFIG_DIR_PATH</Arg>
<Arg>../config/config</Arg>
</Call>
</New>
</Arg>
</Call>
</Configure>
4.安装svn插件
安装这个都没有问题,地址:http://subclipse.tigris.org/update,主要是中文看着别扭,添加一行 osgi.nl=en_US 到%eclipse_home%/configuration/config.ini即可。
安装成功之后,你都可以在window->show view 看到已经安装的插件。
问题1:创建scala project失败
Message:Unhandled event loop exception
Exception Stack Trace:
java.lang.NullPointerException
at scala.tools.eclipse.wizards.NewApplicationPage.setVisible(NewApplicationPage.scala:40)
at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1260)
at org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1239)
at org.eclipse.jface.wizard.WizardDialog$8.run(WizardDialog.java:1228)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1226)
at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:915)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:428)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:257)
at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:277)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
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:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
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:344)
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:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Session Date:
eclipse.buildId=M20120208-0800
java.version=1.6.0_26
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product
对于这个问题,还没有找到解决方法,但是我换了一种方法创建scala 项目,先创建java项目,然后add scala nature。
问题2:导入maven和scala项目,出现Plugin execution not covered by lifecycle configuration: org.scala-tools:maven-scala-plugin:2.14.1:testCompile (execution: default, phase: test-compile)
解决办法:是由于你没有安装maven-scala插件导致的。http://www.assembla.com/wiki/show/scala-ide/With_M2Eclipse有详细的介绍。
下载地址:http://alchim31.free.fr/m2e-scala/update-site/
期间集成maven和scala出现很多问题,多谢小弟和同事的帮忙。