简体   繁体   English

Eclipse中的Grails

[英]Grails in Eclipse

I'm trying to follow some of the introduction to Grails tutorials and am at the point where I want to try to see if I can use a debugger in Eclipse with my Grails applications. 我正在尝试遵循Grails教程的一些介绍,并且正要尝试查看是否可以在我的Grails应用程序中使用Eclipse中的调试器。 My grails application runs fine when I use the command to execute, but when I tried to use the Eclipse run configuration, I get the following error: 当我使用命令执行时,grails应用程序运行良好,但是当我尝试使用Eclipse运行配置时,出现以下错误:

Exception in thread "main" java.lang.NullPointerException
at java.io.File.<init>(File.java:194)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:107)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:192)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:200)
at grails.util.GrailsMain.run(GrailsMain.groovy:27)
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:585)
at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1062)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:893)
at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:744)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:727)
at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:383)
at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:129)
at grails.util.GrailsMain.main(GrailsMain.groovy)

I figure it's a configuration issue (I did recently set the GRAILS_HOME environment variable and that seems to be correct) but that error message doesn't really give me much to go. 我认为这是一个配置问题(我最近确实设置了GRAILS_HOME环境变量,这似乎是正确的),但是该错误消息并没有给我带来太多帮助。

Suggestions? 建议?

Grails does work in Eclipse. Grails确实可以在Eclipse中工作。 Based on my observations I would actually say that it is the preferred IDE for Grails development (well the STS version). 根据我的观察,我实际上会说它是Grails开发的首选IDE(以及STS版本)。

A) You could choose to install the Eclipse groovy plug in. Can be a little fiddly http://groovy.codehaus.org/Eclipse+Plugin A)您可以选择安装Eclipse groovy插件。可以有点儿http://groovy.codehaus.org/Eclipse+Plugin

B) Or you could used the Spring tool suite (STS) IDE and install Grails support from the extensions menu. B)或者您可以使用Spring工具套件(STS)IDE并从扩展菜单安装Grails支持。 http://grails.org/STS+Integration (Just works!) http://grails.org/STS+Integration (行之有效!)

STS is built on Eclipse STS基于Eclipse构建

I personally have found STS to have better Grails support than Netbeans. 我个人发现STS比Netbeans具有更好的Grails支持。 Its developed by the same organisation that backs Grails 它由支持Grails的同一组织开发

Have you installed the Groovy Eclipse Plugin? 您是否已安装了Groovy Eclipse插件?

IIRC, you need this to enable Groovy debugging --- take a look at this page for a step by step about setting up the eclipse debugger - http://www.grails.org/Eclipse+IDE+Integration IIRC,您需要使用它来启用Groovy调试---逐步了解此页面,以设置Eclipse调试器-http: //www.grails.org/Eclipse+IDE+Integration

But Jared is right, Netbeans step debugger is so much nicer --- http://www.grailsblog.com/archive/show?id=13 但是Jared是对的,Netbeans步骤调试器要好得多--- http://www.grailsblog.com/archive/show?id=13

除了grails home外,尝试设置JAVA_HOME环境变量。

I was never able to get grails to work properly in eclipse. 我从没能在日食中正常工作。 You may want to try Netbeans though the 6.7 version has improved grails support. 您可能想尝试Netbeans,尽管6.7版本改进了grails支持。

We use Groovy/Grails Tool Suite IDE. 我们使用Groovy / Grails工具套件 IDE。 It's similar to Spring Tool Suite (STS) in that it's based on Eclipse, but GGTS comes bundled with the Grails distribution itself and the tooling for Eclipse so that there's no extra step required to get any plugins. 它与Spring Tool Suite(STS)相似,因为它基于Eclipse,但是GGTS与Grails发行版本身以及Eclipse的工具捆绑在一起,因此不需要任何额外的步骤即可获得任何插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM