parent
0b9283c3cd
commit
cf28663cd7
|
|
@ -269,8 +269,8 @@
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-dbcp</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-dbcp</artifactId>
|
<artifactId>commons-dbcp2</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Annotation processing -->
|
<!-- Annotation processing -->
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ public class DataSourceBuilder {
|
||||||
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
|
private static final String[] DATA_SOURCE_TYPE_NAMES = new String[] {
|
||||||
"org.apache.tomcat.jdbc.pool.DataSource",
|
"org.apache.tomcat.jdbc.pool.DataSource",
|
||||||
"com.zaxxer.hikari.HikariDataSource",
|
"com.zaxxer.hikari.HikariDataSource",
|
||||||
"org.apache.commons.dbcp.BasicDataSource",
|
"org.apache.commons.dbcp.BasicDataSource", //deprecated
|
||||||
"org.apache.commons.dbcp2.BasicDataSource" };
|
"org.apache.commons.dbcp2.BasicDataSource" };
|
||||||
|
|
||||||
private Class<? extends DataSource> type;
|
private Class<? extends DataSource> type;
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ abstract class DataSourceConfiguration {
|
||||||
|
|
||||||
@ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class)
|
@ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class)
|
||||||
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp.BasicDataSource", matchIfMissing = true)
|
@ConditionalOnProperty(name = "spring.datasource.type", havingValue = "org.apache.commons.dbcp.BasicDataSource", matchIfMissing = true)
|
||||||
|
@Deprecated
|
||||||
static class Dbcp extends DataSourceConfiguration {
|
static class Dbcp extends DataSourceConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -26,6 +26,7 @@ import org.apache.commons.dbcp.BasicDataSource;
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class CommonsDbcpDataSourcePoolMetadata
|
public class CommonsDbcpDataSourcePoolMetadata
|
||||||
extends AbstractDataSourcePoolMetadata<BasicDataSource> {
|
extends AbstractDataSourcePoolMetadata<BasicDataSource> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2014 the original author or authors.
|
* Copyright 2012-2016 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -19,7 +19,7 @@ package org.springframework.boot.autoconfigure.jdbc.metadata;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
@ -78,7 +78,8 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass(BasicDataSource.class)
|
@ConditionalOnClass(org.apache.commons.dbcp.BasicDataSource.class)
|
||||||
|
@Deprecated
|
||||||
static class CommonsDbcpPoolDataSourceMetadataProviderConfiguration {
|
static class CommonsDbcpPoolDataSourceMetadataProviderConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
@ -87,9 +88,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||||
@Override
|
@Override
|
||||||
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
if (dataSource instanceof BasicDataSource) {
|
if (dataSource instanceof org.apache.commons.dbcp.BasicDataSource) {
|
||||||
return new CommonsDbcpDataSourcePoolMetadata(
|
return new CommonsDbcpDataSourcePoolMetadata(
|
||||||
(BasicDataSource) dataSource);
|
(org.apache.commons.dbcp.BasicDataSource) dataSource);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -99,7 +100,7 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnClass(org.apache.commons.dbcp2.BasicDataSource.class)
|
@ConditionalOnClass(BasicDataSource.class)
|
||||||
static class CommonsDbcp2PoolDataSourceMetadataProviderConfiguration {
|
static class CommonsDbcp2PoolDataSourceMetadataProviderConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|
@ -108,9 +109,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
|
||||||
@Override
|
@Override
|
||||||
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
public DataSourcePoolMetadata getDataSourcePoolMetadata(
|
||||||
DataSource dataSource) {
|
DataSource dataSource) {
|
||||||
if (dataSource instanceof org.apache.commons.dbcp2.BasicDataSource) {
|
if (dataSource instanceof BasicDataSource) {
|
||||||
return new CommonsDbcp2DataSourcePoolMetadata(
|
return new CommonsDbcp2DataSourcePoolMetadata(
|
||||||
(org.apache.commons.dbcp2.BasicDataSource) dataSource);
|
(BasicDataSource) dataSource);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
* @author Dave Syer
|
* @author Dave Syer
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class CommonsDbcpDataSourceConfigurationTests {
|
public class CommonsDbcpDataSourceConfigurationTests {
|
||||||
|
|
||||||
private static final String PREFIX = "spring.datasource.dbcp.";
|
private static final String PREFIX = "spring.datasource.dbcp.";
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.logging.Logger;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
@ -138,15 +138,19 @@ public class DataSourceAutoConfigurationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Deprecated
|
||||||
public void commonsDbcpIsFallback() throws Exception {
|
public void commonsDbcpIsFallback() throws Exception {
|
||||||
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
|
||||||
|
org.apache.commons.dbcp.BasicDataSource.class,
|
||||||
"org.apache.tomcat", "com.zaxxer.hikari");
|
"org.apache.tomcat", "com.zaxxer.hikari");
|
||||||
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Deprecated
|
||||||
public void commonsDbcpValidatesConnectionByDefault() {
|
public void commonsDbcpValidatesConnectionByDefault() {
|
||||||
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
org.apache.commons.dbcp.BasicDataSource dataSource = autoConfigureDataSource(
|
||||||
|
org.apache.commons.dbcp.BasicDataSource.class,
|
||||||
"org.apache.tomcat", "com.zaxxer.hikari");
|
"org.apache.tomcat", "com.zaxxer.hikari");
|
||||||
assertThat(dataSource.getTestOnBorrow()).isTrue();
|
assertThat(dataSource.getTestOnBorrow()).isTrue();
|
||||||
assertThat(dataSource.getValidationQuery())
|
assertThat(dataSource.getValidationQuery())
|
||||||
|
|
@ -155,9 +159,8 @@ public class DataSourceAutoConfigurationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void commonsDbcp2IsFallback() throws Exception {
|
public void commonsDbcp2IsFallback() throws Exception {
|
||||||
org.apache.commons.dbcp2.BasicDataSource dataSource = autoConfigureDataSource(
|
BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
|
||||||
org.apache.commons.dbcp2.BasicDataSource.class, "org.apache.tomcat",
|
"org.apache.tomcat", "com.zaxxer.hikari", "org.apache.commons.dbcp.");
|
||||||
"com.zaxxer.hikari", "org.apache.commons.dbcp.");
|
|
||||||
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:testdb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.jmx.export.MBeanExporter;
|
import org.springframework.jmx.export.MBeanExporter;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link JndiDataSourceAutoConfiguration}
|
* Tests for {@link JndiDataSourceAutoConfiguration}
|
||||||
|
|
@ -120,7 +121,7 @@ public class JndiDataSourceAutoConfigurationTests {
|
||||||
@Test
|
@Test
|
||||||
public void standardDataSourceIsNotExcludedFromExport()
|
public void standardDataSourceIsNotExcludedFromExport()
|
||||||
throws IllegalStateException, NamingException {
|
throws IllegalStateException, NamingException {
|
||||||
DataSource dataSource = new org.apache.commons.dbcp.BasicDataSource();
|
DataSource dataSource = mock(DataSource.class);
|
||||||
configureJndi("foo", dataSource);
|
configureJndi("foo", dataSource);
|
||||||
|
|
||||||
this.context = new AnnotationConfigApplicationContext();
|
this.context = new AnnotationConfigApplicationContext();
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.jdbc;
|
package org.springframework.boot.autoconfigure.jdbc;
|
||||||
|
|
||||||
import org.apache.commons.dbcp.BasicDataSource;
|
import org.apache.commons.dbcp2.BasicDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link BasicDataSource} used for testing.
|
* {@link BasicDataSource} used for testing.
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class CommonsDbcpDataSourcePoolMetadataTests
|
public class CommonsDbcpDataSourcePoolMetadataTests
|
||||||
extends AbstractDataSourcePoolMetadataTests<CommonsDbcpDataSourcePoolMetadata> {
|
extends AbstractDataSourcePoolMetadataTests<CommonsDbcpDataSourcePoolMetadata> {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -594,7 +594,6 @@ content into your application; rather pick only the properties that you need.
|
||||||
spring.datasource.data= # Data (DML) script resource reference.
|
spring.datasource.data= # Data (DML) script resource reference.
|
||||||
spring.datasource.data-username= # User of the database to execute DML scripts (if different).
|
spring.datasource.data-username= # User of the database to execute DML scripts (if different).
|
||||||
spring.datasource.data-password= # Password of the database to execute DML scripts (if different).
|
spring.datasource.data-password= # Password of the database to execute DML scripts (if different).
|
||||||
spring.datasource.dbcp.*= # Commons DBCP specific settings
|
|
||||||
spring.datasource.dbcp2.*= # Commons DBCP2 specific settings
|
spring.datasource.dbcp2.*= # Commons DBCP2 specific settings
|
||||||
spring.datasource.driver-class-name= # Fully qualified name of the JDBC driver. Auto-detected based on the URL by default.
|
spring.datasource.driver-class-name= # Fully qualified name of the JDBC driver. Auto-detected based on the URL by default.
|
||||||
spring.datasource.hikari.*= # Hikari specific settings
|
spring.datasource.hikari.*= # Hikari specific settings
|
||||||
|
|
|
||||||
|
|
@ -2690,7 +2690,8 @@ Here's the algorithm for choosing a specific implementation:
|
||||||
that is available we always choose it.
|
that is available we always choose it.
|
||||||
* Otherwise, if HikariCP is available we will use it.
|
* Otherwise, if HikariCP is available we will use it.
|
||||||
* If neither the Tomcat pooling datasource nor HikariCP are available and if Commons DBCP
|
* If neither the Tomcat pooling datasource nor HikariCP are available and if Commons DBCP
|
||||||
is available we will use it, but we don't recommend it in production.
|
is available we will use it, but we don't recommend it in production and its support
|
||||||
|
is deprecated.
|
||||||
* Lastly, if Commons DBCP2 is available we will use it.
|
* Lastly, if Commons DBCP2 is available we will use it.
|
||||||
|
|
||||||
If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa`
|
If you use the `spring-boot-starter-jdbc` or `spring-boot-starter-data-jpa`
|
||||||
|
|
@ -2730,9 +2731,8 @@ See {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[`DataSourc
|
||||||
for more of the supported options. These are the standard options that work regardless of
|
for more of the supported options. These are the standard options that work regardless of
|
||||||
the actual implementation. It is also possible to fine-tune implementation-specific
|
the actual implementation. It is also possible to fine-tune implementation-specific
|
||||||
settings using their respective prefix (`+spring.datasource.tomcat.*+`,
|
settings using their respective prefix (`+spring.datasource.tomcat.*+`,
|
||||||
`+spring.datasource.hikari.*+`, `+spring.datasource.dbcp.*+` and
|
`+spring.datasource.hikari.*+`, and `+spring.datasource.dbcp2.*+`). Refer to the
|
||||||
`+spring.datasource.dbcp2.*+`). Refer to the documentation of the connection pool
|
documentation of the connection pool implementation you are using for more details.
|
||||||
implementation you are using for more details.
|
|
||||||
|
|
||||||
For instance, if you are using the
|
For instance, if you are using the
|
||||||
http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes[Tomcat connection pool]
|
http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes[Tomcat connection pool]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue