Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
cf28663c
Commit
cf28663c
authored
Oct 05, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate commons-dbcp 1
Closes gh-6787
parent
0b9283c3
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
35 additions
and
27 deletions
+35
-27
pom.xml
spring-boot-actuator/pom.xml
+2
-2
PublicMetricsAutoConfigurationTests.java
...te/autoconfigure/PublicMetricsAutoConfigurationTests.java
+1
-1
DataSourceBuilder.java
...gframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
+1
-1
DataSourceConfiguration.java
...work/boot/autoconfigure/jdbc/DataSourceConfiguration.java
+1
-0
CommonsDbcpDataSourcePoolMetadata.java
...gure/jdbc/metadata/CommonsDbcpDataSourcePoolMetadata.java
+2
-1
DataSourcePoolMetadataProvidersConfiguration.java
...etadata/DataSourcePoolMetadataProvidersConfiguration.java
+9
-8
CommonsDbcpDataSourceConfigurationTests.java
...nfigure/jdbc/CommonsDbcpDataSourceConfigurationTests.java
+1
-0
DataSourceAutoConfigurationTests.java
.../autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
+9
-6
JdbcTemplateAutoConfigurationTests.java
...utoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java
+1
-1
JndiDataSourceAutoConfigurationTests.java
...oconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java
+2
-1
TestDataSource.java
...ringframework/boot/autoconfigure/jdbc/TestDataSource.java
+1
-1
CommonsDbcpDataSourcePoolMetadataTests.java
...jdbc/metadata/CommonsDbcpDataSourcePoolMetadataTests.java
+1
-0
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+0
-1
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+4
-4
No files found.
spring-boot-actuator/pom.xml
View file @
cf28663c
...
...
@@ -269,8 +269,8 @@
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
commons-dbcp
</groupId>
<artifactId>
commons-dbcp
</artifactId>
<groupId>
org.apache.commons
</groupId>
<artifactId>
commons-dbcp
2
</artifactId>
<optional>
true
</optional>
</dependency>
<!-- Annotation processing -->
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfigurationTests.java
View file @
cf28663c
...
...
@@ -26,7 +26,7 @@ import java.util.Map;
import
javax.sql.DataSource
;
import
com.zaxxer.hikari.HikariDataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp
2
.BasicDataSource
;
import
org.junit.After
;
import
org.junit.Test
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceBuilder.java
View file @
cf28663c
...
...
@@ -44,7 +44,7 @@ public class DataSourceBuilder {
private
static
final
String
[]
DATA_SOURCE_TYPE_NAMES
=
new
String
[]
{
"org.apache.tomcat.jdbc.pool.DataSource"
,
"com.zaxxer.hikari.HikariDataSource"
,
"org.apache.commons.dbcp.BasicDataSource"
,
"org.apache.commons.dbcp.BasicDataSource"
,
//deprecated
"org.apache.commons.dbcp2.BasicDataSource"
};
private
Class
<?
extends
DataSource
>
type
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration.java
View file @
cf28663c
...
...
@@ -77,6 +77,7 @@ abstract class DataSourceConfiguration {
@ConditionalOnClass
(
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
.
class
)
@ConditionalOnProperty
(
name
=
"spring.datasource.type"
,
havingValue
=
"org.apache.commons.dbcp.BasicDataSource"
,
matchIfMissing
=
true
)
@Deprecated
static
class
Dbcp
extends
DataSourceConfiguration
{
@Bean
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/CommonsDbcpDataSourcePoolMetadata.java
View file @
cf28663c
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (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
* @since 1.2.0
*/
@Deprecated
public
class
CommonsDbcpDataSourcePoolMetadata
extends
AbstractDataSourcePoolMetadata
<
BasicDataSource
>
{
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProvidersConfiguration.java
View file @
cf28663c
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (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
com.zaxxer.hikari.HikariDataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp
2
.BasicDataSource
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.context.annotation.Bean
;
...
...
@@ -78,7 +78,8 @@ public class DataSourcePoolMetadataProvidersConfiguration {
}
@Configuration
@ConditionalOnClass
(
BasicDataSource
.
class
)
@ConditionalOnClass
(
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
.
class
)
@Deprecated
static
class
CommonsDbcpPoolDataSourceMetadataProviderConfiguration
{
@Bean
...
...
@@ -87,9 +88,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
@Override
public
DataSourcePoolMetadata
getDataSourcePoolMetadata
(
DataSource
dataSource
)
{
if
(
dataSource
instanceof
BasicDataSource
)
{
if
(
dataSource
instanceof
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
)
{
return
new
CommonsDbcpDataSourcePoolMetadata
(
(
BasicDataSource
)
dataSource
);
(
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
)
dataSource
);
}
return
null
;
}
...
...
@@ -99,7 +100,7 @@ public class DataSourcePoolMetadataProvidersConfiguration {
}
@Configuration
@ConditionalOnClass
(
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
.
class
)
@ConditionalOnClass
(
BasicDataSource
.
class
)
static
class
CommonsDbcp2PoolDataSourceMetadataProviderConfiguration
{
@Bean
...
...
@@ -108,9 +109,9 @@ public class DataSourcePoolMetadataProvidersConfiguration {
@Override
public
DataSourcePoolMetadata
getDataSourcePoolMetadata
(
DataSource
dataSource
)
{
if
(
dataSource
instanceof
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
)
{
if
(
dataSource
instanceof
BasicDataSource
)
{
return
new
CommonsDbcp2DataSourcePoolMetadata
(
(
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
)
dataSource
);
(
BasicDataSource
)
dataSource
);
}
return
null
;
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/CommonsDbcpDataSourceConfigurationTests.java
View file @
cf28663c
...
...
@@ -37,6 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Dave Syer
* @author Stephane Nicoll
*/
@Deprecated
public
class
CommonsDbcpDataSourceConfigurationTests
{
private
static
final
String
PREFIX
=
"spring.datasource.dbcp."
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfigurationTests.java
View file @
cf28663c
...
...
@@ -30,7 +30,7 @@ import java.util.logging.Logger;
import
javax.sql.DataSource
;
import
com.zaxxer.hikari.HikariDataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp
2
.BasicDataSource
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
@@ -138,15 +138,19 @@ public class DataSourceAutoConfigurationTests {
}
@Test
@Deprecated
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"
);
assertThat
(
dataSource
.
getUrl
()).
isEqualTo
(
"jdbc:hsqldb:mem:testdb"
);
}
@Test
@Deprecated
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"
);
assertThat
(
dataSource
.
getTestOnBorrow
()).
isTrue
();
assertThat
(
dataSource
.
getValidationQuery
())
...
...
@@ -155,9 +159,8 @@ public class DataSourceAutoConfigurationTests {
@Test
public
void
commonsDbcp2IsFallback
()
throws
Exception
{
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
dataSource
=
autoConfigureDataSource
(
org
.
apache
.
commons
.
dbcp2
.
BasicDataSource
.
class
,
"org.apache.tomcat"
,
"com.zaxxer.hikari"
,
"org.apache.commons.dbcp."
);
BasicDataSource
dataSource
=
autoConfigureDataSource
(
BasicDataSource
.
class
,
"org.apache.tomcat"
,
"com.zaxxer.hikari"
,
"org.apache.commons.dbcp."
);
assertThat
(
dataSource
.
getUrl
()).
isEqualTo
(
"jdbc:hsqldb:mem:testdb"
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfigurationTests.java
View file @
cf28663c
...
...
@@ -20,7 +20,7 @@ import java.util.Random;
import
javax.sql.DataSource
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp
2
.BasicDataSource
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfigurationTests.java
View file @
cf28663c
...
...
@@ -36,6 +36,7 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.jmx.export.MBeanExporter
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
* Tests for {@link JndiDataSourceAutoConfiguration}
...
...
@@ -120,7 +121,7 @@ public class JndiDataSourceAutoConfigurationTests {
@Test
public
void
standardDataSourceIsNotExcludedFromExport
()
throws
IllegalStateException
,
NamingException
{
DataSource
dataSource
=
new
org
.
apache
.
commons
.
dbcp
.
BasicDataSource
(
);
DataSource
dataSource
=
mock
(
DataSource
.
class
);
configureJndi
(
"foo"
,
dataSource
);
this
.
context
=
new
AnnotationConfigApplicationContext
();
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/TestDataSource.java
View file @
cf28663c
...
...
@@ -16,7 +16,7 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
jdbc
;
import
org.apache.commons.dbcp.BasicDataSource
;
import
org.apache.commons.dbcp
2
.BasicDataSource
;
/**
* {@link BasicDataSource} used for testing.
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/jdbc/metadata/CommonsDbcpDataSourcePoolMetadataTests.java
View file @
cf28663c
...
...
@@ -27,6 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*
* @author Stephane Nicoll
*/
@Deprecated
public
class
CommonsDbcpDataSourcePoolMetadataTests
extends
AbstractDataSourcePoolMetadataTests
<
CommonsDbcpDataSourcePoolMetadata
>
{
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
cf28663c
...
...
@@ -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-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.dbcp.*= # Commons DBCP 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.hikari.*= # Hikari specific settings
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
cf28663c
...
...
@@ -2690,7 +2690,8 @@ Here's the algorithm for choosing a specific implementation:
that is available we always choose it.
* Otherwise, if HikariCP is available we will use it.
* 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.
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
the actual implementation. It is also possible to fine-tune implementation-specific
settings using their respective prefix (`+spring.datasource.tomcat.*+`,
`+spring.datasource.hikari.*+`, `+spring.datasource.dbcp.*+` and
`+spring.datasource.dbcp2.*+`). Refer to the documentation of the connection pool
implementation you are using for more details.
`+spring.datasource.hikari.*+`, and `+spring.datasource.dbcp2.*+`). Refer to the
documentation of the connection pool implementation you are using for more details.
For instance, if you are using the
http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes[Tomcat connection pool]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment