grails 配置mysql

来源:互联网 发布:java编程工程师培训 编辑:程序博客网 时间:2024/05/17 07:40

grails 配置mysql数据库

  • 修改DataSource.groovy
dataSource {    pooled = true    jmxExport = true    driverClassName = "com.mysql.jdbc.Driver"    username = "root"    password = "123456"}hibernate {    cache.use_second_level_cache = true    cache.use_query_cache = false    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory'    singleSession = true    flush.mode = 'manual'}environments {    development {        dataSource {            dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''            url = "jdbc:mysql://localhost:3306/login_demo?useUnicode=true&characterEncoding=UTF8"        }    }    test {        dataSource {            dbCreate = "update"            url = "jdbc:mysql://localhost:3306/login_demo?useUnicode=true&characterEncoding=UTF8"        }    }    production {        dataSource {            dbCreate = "update"            url = "jdbc:mysql://localhost:3306/login_demo?useUnicode=true&characterEncoding=UTF8"        }    }
  • 在BuildConfig.groovy中的dependencies里添加 runtime “mysql:mysql-connector-java:5.1.6”
 dependencies {        runtime 'mysql:mysql-connector-java:5.1.6'        test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"    }
原创粉丝点击