Groovy on Grails 快速建站

  1. Groovy on Grails 快速建站
  2. grails版本:1.0.2
  3. 首先,确保环境变量中配置了:
  4. GRAILS_HOME=F:/grails-1.0.2
  5. 以下是建站的日志,黑体为用户输入部分:
  6. E:/>mkdir cinwamanblog
  7. E:/>cd cinwamanblog
  8. 创建应用
  9. E:/cinwamanblog>grails create-app
  10. Welcome to Grails 1.0.2 - http://grails.org/
  11. Licensed under Apache Standard License 2.0
  12. Grails home is set to: F:/grails-1.0.2
  13. Base Directory: E:/cinwamanblog
  14. Note: No plugin scripts found
  15. Running script F:/grails-1.0.2/scripts/CreateApp.groovy
  16. Environment set to development
  17. Application name not specified. Please enter:
  18. cinwamanblog
  19.     [mkdir] Created dir: E:/cinwamanblog/cinwamanblog/src
  20.     [mkdir] Created dir: E:/cinwamanblog/cinwamanblog/src/java
  21.     [mkdir] Created dir: E:/cinwamanblog/cinwamanblog/src/groovy
  22. …… 
  23.      [copy] Copying 2 files to E:/cinwamanblog/cinwamanblog
  24.      [copy] Copying 2 files to E:/cinwamanblog/cinwamanblog/web-app/WEB-INF
  25. ……
  26. [propertyfile] Updating property file: E:/cinwamanblog/cinwamanblog/application.
  27. properties
  28. Created Grails Application at E:/cinwamanblog/cinwamanblog
  29. 运行
  30. E:/cinwamanblog/cinwamanblog>grails run-app
  31. Welcome to Grails 1.0.2 - http://grails.org/
  32. Licensed under Apache Standard License 2.0
  33. Grails home is set to: F:/grails-1.0.2
  34. Base Directory: E:/cinwamanblog/cinwamanblog
  35. Note: No plugin scripts found
  36. ……
  37. 2008-09-04 01:15:43.427::INFO:  Started SelectChannelConnector@0.0.0.0:8080
  38. Server running. Browse to http://localhost:8080/cinwamanblog
  39. 2008-09-04 01:16:02.494:/cinwamanblog:INFO:  GSP servlet initialized
  40. 访问:http://localhost:8080/cinwamanblog 测试是否网站建立起来
  41. 创建领域实体
  42. E:/cinwamanblog/cinwamanblog>grails create-domain-class
  43. Welcome to Grails 1.0.2 - http://grails.org/
  44. Licensed under Apache Standard License 2.0
  45. Grails home is set to: F:/grails-1.0.2
  46. Base Directory: E:/cinwamanblog/cinwamanblog
  47. Note: No plugin scripts found
  48. Running script F:/grails-1.0.2/scripts/CreateDomainClass.groovy
  49. Environment set to development
  50.  name not specified. Please enter:
  51. Article
  52.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/grails-app/domain
  53. Created  for Article
  54.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/test/integration
  55. Created Tests for Article
  56. E:/cinwamanblog/cinwamanblog>grails create-domain-class
  57. ……
  58.  name not specified. Please enter:
  59. catalog
  60.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/grails-app/domain
  61. Created  for Catalog
  62.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/test/integration
  63. Created Tests for Catalog
  64. E:/cinwamanblog/cinwamanblog>grails create-domain-class
  65. ……
  66.  name not specified. Please enter:
  67. person
  68.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/grails-app/domain
  69. Created  for Person
  70.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/test/integration
  71. Created Tests for Person
  72. E:/cinwamanblog/cinwamanblog>grails create-domain-class
  73. ……
  74.  name not specified. Please enter:
  75. blog
  76.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/grails-app/domain
  77. Created  for Blog
  78.      [copy] Copying 1 file to E:/cinwamanblog/cinwamanblog/test/integration
  79. Created Tests for Blog
  80. 创建控制类
  81. E:/cinwamanblog/cinwamanblog>grails create-controller
  82. ……
  83. Controller name not specified. Please enter:
  84. blog
  85. ……
  86. E:/cinwamanblog/cinwamanblog>grails create-controller
  87. ……
  88. catalog
  89. ……
  90. E:/cinwamanblog/cinwamanblog>grails create-controller
  91. ……
  92. article
  93. ……
  94. E:/cinwamanblog/cinwamanblog>grails create-controller
  95. ……
  96. person
  97. ……
  98. E:/cinwamanblog/cinwamanblog>
  99. 使用mysql创建3个空库:开发:blog_dev 测试:blog_test 运营:blog_prod
  100. 修改配置文件:
  101. E:/cinwamanblog/cinwamanblog/grails-app/conf/DataSource.groovy
  102. dataSource {
  103.     pooled = true 
  104.   dbCreate = "update" 
  105.   url = "jdbc:mysql://localhost/blog_dev" 
  106.   driverClassName = "com.mysql.jdbc.Driver" 
  107.   username = "root" 
  108.   password = "root" 
  109. }
  110. hibernate {
  111.     cache.use_second_level_cache=true
  112.     cache.use_query_cache=true
  113.     cache.provider_class='org.hibernate.cache.EhCacheProvider'
  114. }
  115. // environment specific settings
  116. environments {
  117.     development {
  118.         dataSource {
  119.             dbCreate = "create-drop" // one of 'create', 'create-drop','update'
  120.             url = "jdbc:mysql://localhost/blog_dev"
  121.         }
  122.     }
  123.     test {
  124.         dataSource {
  125.             dbCreate = "update"
  126.             url = "jdbc:mysql://localhost/blog_test"
  127.         }
  128.     }
  129.     production {
  130.         dataSource {
  131.             dbCreate = "update"
  132.             url = "jdbc:mysql://localhost/blog_prod"
  133.         }
  134.     }
  135. }
  136. ctrl+c 停止应用,然后E:/cinwamanblog/cinwamanblog>grails run-app
  137. 此时,数据库中的表自动创建

你可能感兴趣的:(8,Groovy,grails,groovy,jdbc,mysql,blog,hibernate)