我是Grails中的新成員。我正面臨着一個非常惱人的問題。 爲什麼我的grails應用程序在每次重新啓動應用程序時重置所有表格數據。例如我有Post域的類。當我創建一些數據時,它保存在我的數據庫中。但是當我再次重啓我的應用程序。所有行都重置。我不知道它爲什麼發生。在應用程序的每次重啓時重置Grails MySQL數據庫
檢查我DataSource.groovy中......
dataSource {
pooled = true
driverClassName = "com.mysql.jdbc.Driver"
dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
}
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:mysql://localhost:3306/blog?useUnicode=yes&characterEncoding=UTF-8"
username = "root"
password = ""
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/blog?useUnicode=yes&characterEncoding=UTF-8"
username = "root"
password = ""
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://localhost:3306/blog?useUnicode=yes&characterEncoding=UTF-8"
username = "root"
password = ""
}
}
}
我在本地主機上測試我的應用程序:8080(開發環境)。請澄清我這個問題。
即使在dbCreate =「update」的情況下,您的數據庫也不應該重置 –
只是一個建議:請記住,如果您更改了任何域類,Grails很可能會顯示錯誤,因爲您必須刪除並創建表再次。在這種情況下,將其更改爲'dbCreate =「create」'臨時... – chelder
@chelder是的,你是對的。謝謝 –