让我们来感受一下用Groovy on Grails快速开发带来的体验吧。
1)首先创建一个web工程,输入命令:grails create-app AddressList
输入如下:
D:\temp>grails create-app AddressList
Welcome to Grails 0.6 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:\grails-0.6
Base Directory: D:\temp
Environment set to development
Note: No plugin scripts found
Running script D:\grails-0.6\scripts\CreateApp.groovy
Overriding previous definition of reference to groovyJarSet
[mkdir] Created dir: D:\temp\AddressList\src
[mkdir] Created dir: D:\temp\AddressList\src\java
[mkdir] Created dir: D:\temp\AddressList\src\groovy
[mkdir] Created dir: D:\temp\AddressList\grails-app
[mkdir] Created dir: D:\temp\AddressList\grails-app\controllers
[mkdir] Created dir: D:\temp\AddressList\grails-app\services
[mkdir] Created dir: D:\temp\AddressList\grails-app\domain
[mkdir] Created dir: D:\temp\AddressList\grails-app\taglib
[mkdir] Created dir: D:\temp\AddressList\grails-app\utils
[mkdir] Created dir: D:\temp\AddressList\grails-app\views
[mkdir] Created dir: D:\temp\AddressList\grails-app\views\layouts
[mkdir] Created dir: D:\temp\AddressList\grails-app\i18n
[mkdir] Created dir: D:\temp\AddressList\grails-app\conf
[mkdir] Created dir: D:\temp\AddressList\test
[mkdir] Created dir: D:\temp\AddressList\test\unit
[mkdir] Created dir: D:\temp\AddressList\test\integration
[mkdir] Created dir: D:\temp\AddressList\scripts
[mkdir] Created dir: D:\temp\AddressList\web-app
[mkdir] Created dir: D:\temp\AddressList\web-app\js
[mkdir] Created dir: D:\temp\AddressList\web-app\css
[mkdir] Created dir: D:\temp\AddressList\web-app\images
[mkdir] Created dir: D:\temp\AddressList\web-app\WEB-INF\classes
[mkdir] Created dir: D:\temp\AddressList\web-app\META-INF
[mkdir] Created dir: D:\temp\AddressList\lib
[mkdir] Created dir: D:\temp\AddressList\grails-app\conf\spring
[mkdir] Created dir: D:\temp\AddressList\grails-app\conf\hibernate
[propertyfile] Creating new property file: D:\temp\AddressList\application.prope
rties
[copy] Copying 2 files to D:\temp\AddressList
[copy] Copying 2 files to D:\temp\AddressList\web-app\WEB-INF
[copy] Copying 5 files to D:\temp\AddressList\web-app\WEB-INF\tld
[copy] Copying 130 files to D:\temp\AddressList\web-app
[copy] Copying 1 file to D:\temp\AddressList\grails-app\conf
[copy] Copying 13 files to D:\temp\AddressList\grails-app
[copy] Copying 1 file to D:\temp\AddressList\grails-app\conf\spring
[copy] Copying 1 file to D:\temp\AddressList
[copy] Copying 1 file to D:\temp\AddressList
[copy] Copying 1 file to D:\temp\AddressList
[propertyfile] Updating property file: D:\temp\AddressList\application.propertie
s
Created Grails Application at D:\temp/AddressList
D:\temp>
2)然后进入AddressList目录,创建一个User模型,输入命令:grails create-domain-class User
输出如下:
[attach]22419[/attach]
我们打开grails-app/domain这个目录看到User.groovy,打开看到什么也没有,我们修改这个文件为:
class User {