grails 配置mysql

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"
    }

猜你喜欢

转载自blog.csdn.net/renying8/article/details/73649950
今日推荐