データベースを inbuild H2 から grails の Mysql データベースに変更したいのですが、Grails のドキュメントでは、Datasource.groovy ファイルを変更するとデータベースが変更されると書かれていますが、これは開発環境でのみ機能し、テスト環境では機能しません。 Datasource.groovy ファイルを作成し、mysql からデータベースを削除し、テストを実行しようとすると、成功するだけなので、私が行っている間違いを誰かが助けることができます。
DataSource.groovy ファイルを変更することを提案しているすべてのボディで、stackoverflow のほとんどすべての質問に答えましたが、うまくいきません。
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
username = "root"
logSql =true
password = "root"
properties {
maxActive = -1
minEvictableIdleTimeMillis = 1800000
timeBetweenEvictionRunsMillis = 1800000
numTestsPerEvictionRun = 3
testOnBorrow = true
testWhileIdle = true
connectionProperties = "[autoReconnectForPools=true]"
testOnReturn = true
validationQuery = "SELECT 1"
}
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://127.0.0.1/devenvi"
}
}
test {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://127.0.0.1/testenvi"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://127.0.0.1/prodenvi"
}
}
}