1
我无法将我的内置数据库设置为“update
”。 当我离开应用程序时,它总是被清除,仿佛仍在'create-drop
'上。Grails - 无法将内置数据库设置为“更新”
知道我正在使用MySQL数据库并恢复到内置数据库以便能够与一些不知道如何设置SQL数据库或Tomcat的朋友共享项目可能很有用服务器。
这里是我的DataSource.groovy
文件:
dataSource {
pooled = true
driverClassName = "org.h2.Driver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = true
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:myAppDevDb;MVCC=TRUE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:myAppTestDb;MVCC=TRUE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:myAppProdDb;MVCC=TRUE"
pooled = true
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
timeBetweenEvictionRunsMillis=1800000
numTestsPerEvictionRun=3
testOnBorrow=true
testWhileIdle=true
testOnReturn=true
validationQuery="SELECT 1"
}
}
}
}
任何帮助极大的赞赏。 在此先感谢。
是的。请注意,使用此URL将在应用程序运行的当前工作目录中创建文件'somefile'。使用绝对路径可能更安全,例如'jdbc:h2:/ data/db/somefile:myAppDevDb; MVCC = TRUE'或相对于当前用户主目录:'jdbc:h2:〜/ somefile:myAppDevDb; MVCC = TRUE' – 2012-04-07 19:36:04
非常感谢。它的行为如预期。 – 2012-04-08 13:38:01