【问题标题】:error with deployed Grails app using h2 file DB使用 h2 文件 DB 部署的 Grails 应用程序出错
【发布时间】:2016-02-09 11:20:44
【问题描述】:

我想要一个独立的包,包括 Tomcat 和我的 Grails 2.5 应用程序以及一个 h2 DB 文件。 在 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"

它在我的带有 run-app 的开发机器上运行良好。知道有什么问题吗?

【问题讨论】:

    标签: tomcat grails h2


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2016-09-07
      • 2012-01-30
      • 2011-10-03
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-08
      • 1970-01-01
      相关资源
      最近更新 更多