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
命令: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