使用 h2 文件数据库部署的 Grails 应用程序出错

error with deployed Grails app using h2 file DB

我想要一个独立的包,包括 Tomcat 和我的带有 h2 数据库文件的 Grails 2.5 应用程序。 在 Config.groovy 我设置加载属性文件

grails.config.locations = ["classpath:mytool-config.properties"]

在 mytool-config.properties 我有:

dataSource.username = "sa"
dataSource.password = "db!admin"
dataSource.url = "jdbc:h2:file:E:\MyTool\db\MyTool;MVCC=TRUE;LOCK_TIMEOUT=10000"

文件夹 E:\MyTool\db 当然存在。还尝试放置一个已经创建的 MyTool。h2.db 文件。

我的 DataSources.groovy 看起来像:

dataSource {
    jmxExport = true
    driverClassName = "org.h2.Driver"
    pooled = true
}
hibernate {
    cache.use_second_level_cache = true
    cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
    singleSession = true // configure OSIV singleSession mode
    flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "update"
            logSql = false
        }
        hibernate.cache.use_query_cache = false
    }
    production {
        dataSource {
            dbCreate = "update"             
            logSql = false
        }
        hibernate.cache.use_query_cache = true
    }
}

但是启动 tomcat 服务应用程序不起作用 tomcat7-stdout.2016-02-09.log 我得到:

2016-02-09 11:59:35,797 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initial connections of pool.
java.sql.SQLException: Driver:org.h2.Driver@3871b7bc returned null for URL:"jdbc:h2:file:E:\MyTool\db\MyTool;MVCC=TRUE;LOCK_TIMEOUT=10000"

它在我的开发机器上使用 运行-app 运行良好。知道出了什么问题吗?

我可以通过从属性文件 mytool-config.properties 中删除 " 和空格来修复它。愚蠢的常见错误。

dataSource.username=sa
dataSource.password=db!admin
ataSource.url=jdbc:h2:file:E:\MyTool\db\MyTool;MVCC=TRUE;LOCK_TIMEOUT=10000