如何在Eclipse中开发Grails项目

canca16年前 (2008-11-03)Groovy and Grails225
1、环境变量:
配置GRAILS_HOME,注意一定要配置到build.xml所在的文件夹:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

2、Eclipse装上Groovy-Eclipse插件,可以使用link方式。

3、导入Grails工程,并选中"Copy projects into workspace"

4、工程的属性中,选中:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.
这样就阻止了groovy文件被Eclipse编译成class文件。

5、工程属性的Java Build Path中,选择Libraries,选择Add Variable,添加变量GRAILS_HOME,并将其中的所有文件夹内的所有jar文件全部引入工程(可以使用shift键批量选中):
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

6、在工程属性的Java Compiler的Building中,选中Enable project specific settings,在最下面的Filtered Resource中,添加*.groovy类型,类型之间使用逗号分隔,这样就能阻止编译器将groovy文件拷贝到web-app/classes文件夹中:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

7、在Window的Preference中选择General,其中Editor的File Associations,添加gsp的文件类型,关联编辑器选择jsp文件的编辑器:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

8、在Window的Preference中选择General,其中Content Types,为jsp类型添加gsp文件关联:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

9、选择Run、External Tools的Open External Tools Dialog,如下配置,这样就可以在Eclipse中启用Grails控制命令了:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

10、选择Run、Open Run Dialog,如下配置,将Grails的项目作为Java应用程序的方式运行:
如何在Eclipse中开发Grails项目 - Canca Torvals - Ant Software Studio.

好了,以上就是整个在Eclipse中配置Grails项目的过程,配置完了,就快去尝试尝试Grails的特性吧!

还有不明白的可以联系我。

//----------------------------------------------------------------------------------------------
跟据以上方法操作后,你会发现在ECLIPSE里,spring/resources.groovy会提示错误!!在国内找不到解决方法,在外国网,找到了这个解决方法:

This is a groovy plugin bug, not a Grails bug.

There is a workaround though - check the Disable Check Package Matches Source
Directory checkbox and the error message goes away. Of course this means that
you'll have issues if a package doesn't match the folder the file is in, but
that's unlikely and the bug is pretty annoying. This is the first thing I do
with new projects now, after setting the bin-groovy output location
directory.

Burt

具体内容就不作翻译了!!

相关文章

Groovy的一些中文资料

IMB的资料—— 精通Groovy:https://www6.software.ibm.com/developerworks/cn/education/java/j-groovy/index.html...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。