【发布时间】:2013-03-14 20:53:10
【问题描述】:
对于单元测试(如果需要,可以将它们称为集成测试),我在 Spring 配置中配置了一个嵌入式数据库,如下所示:
<jdbc:embedded-database id="dataSource" type="H2">
<jdbc:script location="classpath:schema_h2.sql" />
</jdbc:embedded-database>
现在,当从命令行运行测试时,它们工作正常,但最后我得到了一些错误(无害,但令人恼火):
WARN 2013-03-25 12:20:22,656 [Thread-9] o.s.j.d.e.H2EmbeddedDatabaseConfigurer 'Could not shutdown embedded database'
org.h2.jdbc.JdbcSQLException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.170.jar:1.3.170]
...
at org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFactoryBean.destroy(EmbeddedDatabaseFactoryBean.java:65) [spring-jdbc-3.2.1.RELEASE.jar:3.2.1.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:238) [spring-beans-3.2.1.RELEASE.jar:3.2.1.RELEASE]
现在异常中包含的提示通常很好,但是如何将此属性添加到嵌入式数据源?我是否必须扩展它,可以说是手动配置,添加这样的‘高级’功能?
【问题讨论】: