ubuntu 下配置grails

来源:互联网 发布:淘宝托管公司排名 编辑:程序博客网 时间:2024/04/30 00:31

1. 从http://www.grails.org/Download下载最新版的grails

2. 解压文件:unzip grails-1.2.5.zip

3. 将解压后的文件夹移到/urs/lib/ :sudo mv  grails-1.2.5 /usr/lib/

4. 设置grails环境,在/etc/profile增加:

#set grail environment

export GRAILS_HOME=/usr/lib/grails-1.2.5

export PATH=$GRAILS_HOME/bin:$PATH

5. 使设置生效:source /etc/profile

6. 查看GRAILS_HOME的值:echo $GRAILS_HOME

/usr/lib/grails-1.2.5

7. grails 
Welcome to Grails 1.2.5 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/lib/grails-1.2.5
8. 创建HelloGrails
grails create-app HelloGrails
9. cd HelloGrails
10. grails create-domain-class org.example.Book 
11. cd grails-app/domain/org/example/
12. gedit Book.groovy 
package org.example
class Book {
String title
String author
static constraints = {
title(blank: false)
author(blank: false)
}
}
13 cd ../../../..
14 grails create-controller org.example.Book
15 gedit grails-app/controllers/org/example/BookController.groovy 
package org.example
class BookController {
    def scaffold = Book // Note the capital "B"
}
16 grails run-app
17 浏览http://localhost:8080/HelloGrails/book/