(Quick Reference)

2.14 创建工件 - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

2.14 创建工件

Grails ships with a few convenience targets such as create-controller, create-domain-class and so on that will create Controllers and different artefact types for you.
These are just for your convenience and you can just as easily use an IDE or your favourite text editor.
For example to create the basis of an application you typically need a domain model:

grails create-domain-class book

This will result in the creation of a domain class at grails-app/domain/Book.groovy such as:

class Book {
}

There are many such create-* commands that can be explored in the command line reference guide.

To decrease the amount of time it takes to run Grails scripts, use the interactive mode.

Grails还为我们提供了像create-controllercreate-domain-class等命令,以方便地创建控制器和其他的工件类型。

这些仅仅是方便而已,你依然可以轻松的使用IDE或者你自己喜爱的文本编辑器(比如记事本、TextMate、VIM等--译者注)。
以创建一个基本的应用为例,你通常至少需要一个领域模型,比如:

grails create-domain-class book

将会在 grails-app/domain/Book.groovy 中创建一个如下所示的领域类:

class Book {
}

在命令行参考指南中,你还可以看到更多 create-* 命令。

为了减少Grails脚本的运行时间,请使用commandLine模式。