Add destroyMethods to DataSources
This commit is contained in:
@@ -47,7 +47,7 @@ public class CommonsDataSourceConfiguration extends AbstractDataSourceConfigurat
|
|||||||
setInitialSize(0);
|
setInitialSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean(destroyMethod = "close")
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
|
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
|
||||||
+ "but the Tomcat DataSource is more reliable.");
|
+ "but the Tomcat DataSource is more reliable.");
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public enum EmbeddedDatabaseConnection {
|
|||||||
/**
|
/**
|
||||||
* H2 Database Connection.
|
* H2 Database Connection.
|
||||||
*/
|
*/
|
||||||
H2(EmbeddedDatabaseType.H2, "org.h2.Driver", "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1"),
|
H2(EmbeddedDatabaseType.H2, "org.h2.Driver",
|
||||||
|
"jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Derby Database Connection.
|
* Derby Database Connection.
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class TomcatDataSourceConfiguration extends AbstractDataSourceConfigurati
|
|||||||
|
|
||||||
private org.apache.tomcat.jdbc.pool.DataSource pool;
|
private org.apache.tomcat.jdbc.pool.DataSource pool;
|
||||||
|
|
||||||
@Bean
|
@Bean(destroyMethod = "close")
|
||||||
public DataSource dataSource() {
|
public DataSource dataSource() {
|
||||||
this.pool = new org.apache.tomcat.jdbc.pool.DataSource();
|
this.pool = new org.apache.tomcat.jdbc.pool.DataSource();
|
||||||
this.pool.setDriverClassName(getDriverClassName());
|
this.pool.setDriverClassName(getDriverClassName());
|
||||||
|
|||||||
Reference in New Issue
Block a user