Merge branch '1.5.x' into 2.0.x

pull/13710/merge
Andy Wilkinson 6 years ago
commit 57e2bb9c6a

@ -38,7 +38,7 @@ import org.springframework.util.StringUtils;
abstract class DataSourceConfiguration { abstract class DataSourceConfiguration {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
protected <T> T createDataSource(DataSourceProperties properties, protected static <T> T createDataSource(DataSourceProperties properties,
Class<? extends DataSource> type) { Class<? extends DataSource> type) {
return (T) properties.initializeDataSourceBuilder().type(type).build(); return (T) properties.initializeDataSourceBuilder().type(type).build();
} }
@ -47,8 +47,9 @@ abstract class DataSourceConfiguration {
* Tomcat Pool DataSource configuration. * Tomcat Pool DataSource configuration.
*/ */
@ConditionalOnClass(org.apache.tomcat.jdbc.pool.DataSource.class) @ConditionalOnClass(org.apache.tomcat.jdbc.pool.DataSource.class)
@ConditionalOnMissingBean(DataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.tomcat.jdbc.pool.DataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.tomcat.jdbc.pool.DataSource", matchIfMissing = true)
static class Tomcat extends DataSourceConfiguration { static class Tomcat {
@Bean @Bean
@ConfigurationProperties(prefix = "spring.datasource.tomcat") @ConfigurationProperties(prefix = "spring.datasource.tomcat")
@ -72,8 +73,9 @@ abstract class DataSourceConfiguration {
* Hikari DataSource configuration. * Hikari DataSource configuration.
*/ */
@ConditionalOnClass(HikariDataSource.class) @ConditionalOnClass(HikariDataSource.class)
@ConditionalOnMissingBean(DataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "com.zaxxer.hikari.HikariDataSource", matchIfMissing = true)
static class Hikari extends DataSourceConfiguration { static class Hikari {
@Bean @Bean
@ConfigurationProperties(prefix = "spring.datasource.hikari") @ConfigurationProperties(prefix = "spring.datasource.hikari")
@ -92,8 +94,9 @@ abstract class DataSourceConfiguration {
* DBCP DataSource configuration. * DBCP DataSource configuration.
*/ */
@ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class) @ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class)
@ConditionalOnMissingBean(DataSource.class)
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp2.BasicDataSource", matchIfMissing = true) @ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp2.BasicDataSource", matchIfMissing = true)
static class Dbcp2 extends DataSourceConfiguration { static class Dbcp2 {
@Bean @Bean
@ConfigurationProperties(prefix = "spring.datasource.dbcp2") @ConfigurationProperties(prefix = "spring.datasource.dbcp2")

Loading…
Cancel
Save