Groovy轻松入门——Grails实战基础篇(1)

在学习任何东西之前,最重要的是培养兴趣,Groovy世界最耀眼的技术之一--Grails相信大家早已耳闻,我将通过Grails实战系列文章向您展现Grails的迷人风采,使您感受到Grails的魅力,以至疯狂地爱上Grails,并坠入Groovy的爱河。学Groovy,Grails与学Java一样,在实战之前需要搭建开发环境,您可以在 Groovy轻松入门--搭建Groovy开发环境 学习到如何搭建Groovy环境,之后我会讲一下如何搭建Grails环境,然后手把手地写个Demo程序告终,我还会抽空写篇“Groovy轻松入门--Grails实战之进阶篇”

一,搭建Grails环境

0,下载Grails( http://dist.codehaus.org/grails/grails-bin-0.4.2.zip ,请留意朝花夕拾——Groovy & Grails中的“最新版本”提示)并解压到自己指定位置(我的位置是D:/D/MY_DEV/grails)

1,设置环境变量GRAILS_HOME(注意大写),过程与“设置环境变量GROOVY_HOME”相似。

2,将%GRAILS_HOME%/bin添加到环境变量path中,过程与“将GROOVY_HOME目录下的bin追加到环境变量path中”相似。

(如果只想进行Grails开发,可以不设GROOVY_HOME)

二,创建Grails Demo程序

0,打开“命令行”,选择当前目录(我的为D:/Temp/grails_apps),在黑底白字的窗口中输入“grails create-app demo”,不包括双引号“”,在您的屏幕中可以看到类似下面的输出结果:

D:/Temp/grails_apps>grails create-app demo

Welcome to Grails 0.4.2 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: D:/D/MY_DEV/grails

Base Directory: D:/Temp/grails_apps
Environment set to production
Note: No plugin scripts found
Running script D:/D/MY_DEV/grails/scripts/CreateApp.groovy
    [mkdir] Created dir: D:/Temp/grails_apps/demo/src
    [mkdir] Created dir: D:/Temp/grails_apps/demo/src/java
    [mkdir] Created dir: D:/Temp/grails_apps/demo/src/groovy
    [mkdir] Created dir: D:/Temp/grails_apps/demo/src/test
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/controllers
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/services
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/domain
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/taglib
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/utils
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/views
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/views/layouts
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/i18n
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-app/conf
    [mkdir] Created dir: D:/Temp/grails_apps/demo/grails-tests
    [mkdir] Created dir: D:/Temp/grails_apps/demo/scripts
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app/js
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app/css
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app/images
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app/WEB-INF/classes
    [mkdir] Created dir: D:/Temp/grails_apps/demo/web-app/meta-inf
    [mkdir] Created dir: D:/Temp/grails_apps/demo/lib
    [mkdir] Created dir: D:/Temp/grails_apps/demo/spring
    [mkdir] Created dir: D:/Temp/grails_apps/demo/hibernate
     [copy] copying 2 files to D:/Temp/grails_apps/demo
     [copy] copying 2 files to D:/Temp/grails_apps/demo/web-app/WEB-INF
     [copy] copying 1 file to D:/Temp/grails_apps/demo/web-app/WEB-INF
     [copy] copying 1 file to D:/Temp/grails_apps/demo/web-app/WEB-INF
     [copy] copying 5 files to D:/Temp/grails_apps/demo/web-app/WEB-INF/tld
     [copy] copying 119 files to D:/Temp/grails_apps/demo/web-app
     [copy] copying 1 file to D:/Temp/grails_apps/demo/grails-app/conf
     [copy] copying 1 file to D:/Temp/grails_apps/demo/grails-app/conf
     [copy] copying 1 file to D:/Temp/grails_apps/demo/grails-app/conf
     [copy] copying 7 files to D:/Temp/grails_apps/demo/grails-app
    [mkdir] Created dir: D:/Temp/grails_apps/demo/plugins/core/grails-app/taglib

    [mkdir] Created dir: D:/Temp/grails_apps/demo/plugins/core/grails-app/utils
     [copy] copying 7 files to D:/Temp/grails_apps/demo/plugins/core/grails-app/
taglib
     [copy] copying 3 files to D:/Temp/grails_apps/demo/plugins/core/grails-app/
utils
     [copy] copying 1 file to D:/Temp/grails_apps/demo/spring
     [copy] copying 1 file to D:/Temp/grails_apps/demo
     [copy] copying 1 file to D:/Temp/grails_apps/demo
     [copy] copying 1 file to D:/Temp/grails_apps/demo
Created Grails Application at D:/Temp/grails_apps/demo
D:/Temp/grails_apps>

相关文章

背景:    8月29日,凌晨4点左右,某服务告警,其中一个...
https://support.smartbear.comeadyapi/docs/soapui/steps/g...
有几个选项可用于执行自定义JMeter脚本并扩展基线JMeter功能...
Scala和Java为静态语言,Groovy为动态语言Scala:函数式编程,...
出处:https://www.jianshu.com/p/ce6f8a1f66f4一、一些内部...
在运行groovy的junit方法时,报了这个错误:java.lang.Excep...