grails h2数据库创建表

Bob*_*Bob 2 database grails h2

我有一个非常简单的域类

class Person {

  String code

}
Run Code Online (Sandbox Code Playgroud)

我也使用默认的DataSource配置:

dataSource {
  pooled = true
  driverClassName = "org.h2.Driver"
  username = "sa"
  password = ""
}
hibernate {
  cache.use_second_level_cache = true
  cache.use_query_cache = false
  cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
  development {
    dataSource {
      dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
      url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
      dialect = "org.hibernate.dialect.H2Dialect"
    }
  } ...
Run Code Online (Sandbox Code Playgroud)

但是当我打开/ dbconsole然后我看到DB是空的并且没有表.为什么?我做错了什么?

Ali*_*dad 6

当你打开它时,dbconsole你必须确保它读取正确的数据库.

在您的网址部分中,将dbconsole指向您的应用正在使用的网址.在你的情况下:

jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000
Run Code Online (Sandbox Code Playgroud)