Clarify use of the spring.datasource prefix
Previously, Spring Boot mapped both `DataSourceProperties` and the actual `DataSource` implementation to the same prefix. This results in a huge amount of keys in the `spring.datasource` namespace with no way to identify those that are valid for the pooled data source in use. This commit maps the four pooled data sources we support in four isolated namespace, keeping `spring.datasource` only for the common settings. These are `spring.datasource.tomcat`, `spring.datasource.hikari`, `spring.datasource.dbcp` and `spring.datasource.dbcp2` for the Tomcat, Hikari, Commons DBCP and Commons DBCP2 implementations respectively. Closes gh-2183
This commit is contained in:
@@ -525,7 +525,10 @@ content into your application; rather pick only the properties that you need.
|
||||
# DATASOURCE ({sc-spring-boot-autoconfigure}/jdbc/DataSourceAutoConfiguration.{sc-ext}[DataSourceAutoConfiguration] & {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[DataSourceProperties])
|
||||
spring.datasource.continue-on-error=false # Do not stop if an error occurs while initializing the database.
|
||||
spring.datasource.data= # Data (DML) script resource reference.
|
||||
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.datasource.initialize=true # Populate the database using 'data.sql'.
|
||||
spring.datasource.jmx-enabled=false # Enable JMX support (if provided by the underlying pool).
|
||||
spring.datasource.jndi-name= # JNDI location of the datasource. Class, url, username & password are ignored when set.
|
||||
@@ -544,6 +547,7 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.datasource.test-on-return= # For instance `false`
|
||||
spring.datasource.test-while-idle= #
|
||||
spring.datasource.time-between-eviction-runs-millis= 1
|
||||
spring.datasource.tomcat.*= # Tomcat datasource specific settings
|
||||
spring.datasource.type= # Fully qualified name of the connection pool implementation to use. By default, it is auto-detected from the classpath.
|
||||
spring.datasource.url= # JDBC url of the database.
|
||||
spring.datasource.username=
|
||||
|
||||
@@ -293,10 +293,10 @@ following attributes:
|
||||
[[configuration-metadata-repeated-items]]
|
||||
==== Repeated meta-data items
|
||||
It is perfectly acceptable for "`property`" and "`group`" objects with the same name to
|
||||
appear multiple times within a meta-data file. For example, Spring Boot binds
|
||||
`spring.datasource` properties to Hikari, Tomcat and DBCP classes, with each potentially
|
||||
offering overlap of property names. Consumers of meta-data should take care to ensure
|
||||
that they support such scenarios.
|
||||
appear multiple times within a meta-data file. For example, you could bind two separate
|
||||
classes to the same prefix, with each potentially offering overlap of property names.
|
||||
While this is not supposed to be a frequent scenario, consumers of meta-data should take
|
||||
care to ensure that they support such scenarios.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1670,7 +1670,7 @@ to start. The script locations can be changed by setting `spring.datasource.sche
|
||||
`spring.datasource.data`, and neither location will be processed if
|
||||
`spring.datasource.initialize=false`.
|
||||
|
||||
To disable the fail-fast you can set `spring.datasource.continueOnError=true`. This can be
|
||||
To disable the fail-fast you can set `spring.datasource.continue-on-error=true`. This can be
|
||||
useful once an application has matured and been deployed a few times, since the scripts
|
||||
can act as '`poor man's migrations`' -- inserts that fail mean that the data is already
|
||||
there, so there would be no need to prevent the application from running, for instance.
|
||||
|
||||
@@ -2337,8 +2337,10 @@ loadable.
|
||||
|
||||
See {sc-spring-boot-autoconfigure}/jdbc/DataSourceProperties.{sc-ext}[`DataSourceProperties`]
|
||||
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 the `+spring.datasource.*+` prefix, refer to the documentation of the connection pool
|
||||
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.
|
||||
|
||||
For instance, if you are using the
|
||||
@@ -2349,13 +2351,13 @@ you could customize many additional settings:
|
||||
[source,properties,indent=0]
|
||||
----
|
||||
# Number of ms to wait before throwing an exception if no connection is available.
|
||||
spring.datasource.max-wait=10000
|
||||
spring.datasource.tomcat.max-wait=10000
|
||||
|
||||
# Maximum number of active connections that can be allocated from this pool at the same time.
|
||||
spring.datasource.max-active=50
|
||||
spring.datasource.tomcat.max-active=50
|
||||
|
||||
# Validate the connection before borrowing it from the pool.
|
||||
spring.datasource.test-on-borrow=true
|
||||
spring.datasource.tomcat.test-on-borrow=true
|
||||
----
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user