domain类可以使用 create-domain-class 命令来创建:grails create-domain-class Person
这将在 grails-app/domain/Person.groovy 位置上创建类,
如下:class Person {
}
如果在 DataSource 上设置dbCreate属性为"update", “create” or “createdrop”,Grails 会为你自动生成/修改数据表格。
你可以通过添加属性来自定义类:class Person {
String name
Integer age
Date lastVisit
}
一旦你拥有一个 domain 类,可以尝试通过在 shell 或 console 上输入:grails console
这会载入一个交互式GUI,便于你键入Groovy 命令。