mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add destroyMethods to DataSources
This commit is contained in:
parent
c5584b490a
commit
19ca4d4eae
@ -47,7 +47,7 @@ public class CommonsDataSourceConfiguration extends AbstractDataSourceConfigurat
|
||||
setInitialSize(0);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Bean(destroyMethod = "close")
|
||||
public DataSource dataSource() {
|
||||
logger.info("Hint: using Commons DBCP BasicDataSource. It's going to work, "
|
||||
+ "but the Tomcat DataSource is more reliable.");
|
||||
|
@ -36,7 +36,8 @@ public enum EmbeddedDatabaseConnection {
|
||||
/**
|
||||
* 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.
|
||||
|
@ -34,7 +34,7 @@ public class TomcatDataSourceConfiguration extends AbstractDataSourceConfigurati
|
||||
|
||||
private org.apache.tomcat.jdbc.pool.DataSource pool;
|
||||
|
||||
@Bean
|
||||
@Bean(destroyMethod = "close")
|
||||
public DataSource dataSource() {
|
||||
this.pool = new org.apache.tomcat.jdbc.pool.DataSource();
|
||||
this.pool.setDriverClassName(getDriverClassName());
|
||||
|
Loading…
Reference in New Issue
Block a user