Spring的嵌入式H2数据源和DB_CLOSE_ON_EXIT
对于单元测试(如果需要,可以称之为集成测试),我已经在我的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]
现在,异常中包含的提示通常很好,但是如何将此属性添加到嵌入数据源?我是否必须扩展它,手动配置它,可以这么说,以添加这样的“高级”功能?