- Groovy on Grails 快速建站
- grails版本: 1.0 . 2
- 首先,确保环境变量中配置了:
- GRAILS_HOME=F:\grails- 1.0 . 2
- 以下是建站的日志,黑体为用户输入部分:
- E:\>mkdir cinwamanblog
- E:\>cd cinwamanblog
- 创建应用
- E:\cinwamanblog>grails create-app
- Welcome to Grails 1.0 . 2 - http: //grails.org/
- Licensed under Apache Standard License 2.0
- Grails home is set to: F:\grails- 1.0 . 2
- Base Directory: E:\cinwamanblog
- Note: No plugin scripts found
- Running script F:\grails- 1.0 . 2 \scripts\CreateApp.groovy
- Environment set to development
- Application name not specified. Please enter:
- cinwamanblog
- [mkdir] Created dir: E:\cinwamanblog\cinwamanblog\src
- [mkdir] Created dir: E:\cinwamanblog\cinwamanblog\src\java
- [mkdir] Created dir: E:\cinwamanblog\cinwamanblog\src\groovy
- ……
- [copy] Copying 2 files to E:\cinwamanblog\cinwamanblog
- [copy] Copying 2 files to E:\cinwamanblog\cinwamanblog\web-app\WEB-INF
- ……
- [propertyfile] Updating property file: E:\cinwamanblog\cinwamanblog\application.
- properties
- Created Grails Application at E:\cinwamanblog/cinwamanblog
- 运行
- E:\cinwamanblog\cinwamanblog>grails run-app
- Welcome to Grails 1.0 . 2 - http: //grails.org/
- Licensed under Apache Standard License 2.0
- Grails home is set to: F:\grails- 1.0 . 2
- Base Directory: E:\cinwamanblog\cinwamanblog
- Note: No plugin scripts found
- ……
- 2008 - 09 - 04 01 : 15 : 43.427 ::INFO: Started SelectChannelConnector @0 .0. 0.0 : 8080
- Server running. Browse to http: //localhost:8080/cinwamanblog
- 2008 - 09 - 04 01 : 16 : 02.494 :/cinwamanblog:INFO: GSP servlet initialized
- 访问:http: //localhost:8080/cinwamanblog 测试是否网站建立起来
- 创建领域实体
- E:\cinwamanblog\cinwamanblog>grails create-domain- class
- Welcome to Grails 1.0 . 2 - http: //grails.org/
- Licensed under Apache Standard License 2.0
- Grails home is set to: F:\grails- 1.0 . 2
- Base Directory: E:\cinwamanblog\cinwamanblog
- Note: No plugin scripts found
- Running script F:\grails- 1.0 . 2 \scripts\CreateDomainClass.groovy
- Environment set to development
- name not specified. Please enter:
- Article
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\grails-app\domain
- Created for Article
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\test\integration
- Created Tests for Article
- E:\cinwamanblog\cinwamanblog>grails create-domain- class
- ……
- name not specified. Please enter:
- catalog
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\grails-app\domain
- Created for Catalog
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\test\integration
- Created Tests for Catalog
- E:\cinwamanblog\cinwamanblog>grails create-domain- class
- ……
- name not specified. Please enter:
- person
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\grails-app\domain
- Created for Person
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\test\integration
- Created Tests for Person
- E:\cinwamanblog\cinwamanblog>grails create-domain- class
- ……
- name not specified. Please enter:
- blog
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\grails-app\domain
- Created for Blog
- [copy] Copying 1 file to E:\cinwamanblog\cinwamanblog\test\integration
- Created Tests for Blog
- 创建控制类
- E:\cinwamanblog\cinwamanblog>grails create-controller
- ……
- Controller name not specified. Please enter:
- blog
- ……
- E:\cinwamanblog\cinwamanblog>grails create-controller
- ……
- catalog
- ……
- E:\cinwamanblog\cinwamanblog>grails create-controller
- ……
- article
- ……
- E:\cinwamanblog\cinwamanblog>grails create-controller
- ……
- person
- ……
- E:\cinwamanblog\cinwamanblog>
- 使用mysql创建 3 个空库:开发:blog_dev 测试:blog_test 运营:blog_prod
- 修改配置文件:
- E:\cinwamanblog\cinwamanblog\grails-app\conf\DataSource.groovy
- dataSource {
- pooled = true
- dbCreate = "update"
- url = "jdbc:mysql://localhost/blog_dev"
- driverClassName = "com.mysql.jdbc.Driver"
- username = "root"
- password = "root"
- }
- hibernate {
- cache.use_second_level_cache= true
- cache.use_query_cache= true
- cache.provider_class= 'org.hibernate.cache.EhCacheProvider'
- }
- // environment specific settings
- environments {
- development {
- dataSource {
- dbCreate = "create-drop" // one of 'create', 'create-drop','update'
- url = "jdbc:mysql://localhost/blog_dev"
- }
- }
- test {
- dataSource {
- dbCreate = "update"
- url = "jdbc:mysql://localhost/blog_test"
- }
- }
- production {
- dataSource {
- dbCreate = "update"
- url = "jdbc:mysql://localhost/blog_prod"
- }
- }
- }
- ctrl+c 停止应用,然后E:\cinwamanblog\cinwamanblog>grails run-app
- 此时,数据库中的表自动创建
Groovy on Grails 快速建站1
最新推荐文章于 2021-02-28 03:24:03 发布