grails v2.0.1配置已被外化为文件,以便它可以位于安全分区上。当数据源丢失时,如何防止Bootstrap数据迁移运行
这是通过修改Config.groovy中和DataSource.groovy的
grails.config.locations = ["file:/Volumes/secure/local.config.groovy"]
当此添加的配置位置不可做,引导代码无法连接到数据库,我得到这个令人困惑的错误:
运行Grails应用程序 错误util.JDBCExceptionReporter - 未找到表“USER”; SQL语句: select count(*)as y0_ from user this_ ;嵌套异常是org.hibernate.exception.SQLGrammarException:无法执行查询
我想要一个错误,告诉我数据源不可用。我需要改变我的grails配置才能做到这一点?
class BootStrap {
def init = { servletContext ->
if (!User.count()) {
setupAdminUsers() // inserts admin user for shiro
}
}
}