Grails使用之:开始

1.创建应用

命令:grails create-app

生成的目录结构如下:
%PROJECT_HOME%
+ grails-app
+ conf ---> location of configuration artifacts like data sources
+ hibernate ---> optional hibernate config
+ spring ---> optional spring config
+ controllers ---> location of controller artifacts
+ domain ---> location of domain classes
+ i18n ---> location of message bundles for i18n
+ services ---> location of services
+ taglib ---> location of tag libraries
+ util ---> location of special utility classes (e.g., codecs, etc.)
+ views ---> location of views
+ layouts ---> location of layouts
+ lib
+ scripts ---> scripts
+ src
+ groovy ---> optional; location for Groovy source files
(of types other than those in grails-app/*)
+ java ---> optional; location for Java source files
+ test ---> generated test classes
+ web-app
+ WEB-INF

2.配置数据源(可选)

对应文件:%PROJECT_HOME%\grails-app\conf\DataSource.groovy

不使用默认数据源时,用以下命令启动应用,比如数据源文件为SosDataSource.groovy
命令:grails create-appgrails -Dgrails.env=sos run-app

3.创建域对象

命令:grails create-domain-class

生成以下文件:
%PROJECT_HOME%\grails-app\domain\ScsChannel.groovy
%PROJECT_HOME%\test\integration\ScsChannelTests.groovy

3.创建控制器

命令:grails create-controller

生成以下文件:
%PROJECT_HOME%\grails-app\controllers\ScsChannelController.groovy

def scaffold = ScsChannel

%PROJECT_HOME%\test\integration\ScsChannelControllerTests.groovy

%PROJECT_HOME%\grails-app\views\scsChannel

4.开始Grails

命令:grails run-app
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值