Class DataSourceProperties
java.lang.Object
org.springframework.boot.autoconfigure.jdbc.DataSourceProperties
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,InitializingBean
@ConfigurationProperties(prefix="spring.datasource")
public class DataSourceProperties
extends Object
implements BeanClassLoaderAware, InitializingBean
Base class for configuration of a data source.
- Since:
- 1.1.0
- Author:
- Dave Syer, Maciej Walkowiak, Stephane Nicoll, Benedikt Ritter, EddĂș MelĂ©ndez, Scott Frederick
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
XA Specific datasource settings. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Determine the name to used based on this configuration.Determine the driver to use based on this configuration and the environment.Determine the password to use based on this configuration and the environment.Determine the url to use based on this configuration and the environment.Determine the username to use based on this configuration and the environment.Return the configured driver ornull
if none was configured.getName()
Return the configured password ornull
if none was configured.Class<? extends DataSource>
getType()
getUrl()
Return the configured url ornull
if none was configured.Return the configured username ornull
if none was configured.getXa()
Initialize aDataSourceBuilder
with the state of this instance.boolean
void
setBeanClassLoader
(ClassLoader classLoader) void
setDriverClassName
(String driverClassName) void
setEmbeddedDatabaseConnection
(EmbeddedDatabaseConnection embeddedDatabaseConnection) void
setGenerateUniqueName
(boolean generateUniqueName) void
setJndiName
(String jndiName) Allows the DataSource to be managed by the container and obtained through JNDI.void
void
setPassword
(String password) void
setType
(Class<? extends DataSource> type) void
void
setUsername
(String username) void
-
Constructor Details
-
DataSourceProperties
public DataSourceProperties()
-
-
Method Details
-
setBeanClassLoader
- Specified by:
setBeanClassLoader
in interfaceBeanClassLoaderAware
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
initializeDataSourceBuilder
Initialize aDataSourceBuilder
with the state of this instance.- Returns:
- a
DataSourceBuilder
initialized with the customizations defined on this instance
-
isGenerateUniqueName
public boolean isGenerateUniqueName() -
setGenerateUniqueName
public void setGenerateUniqueName(boolean generateUniqueName) -
getName
-
setName
-
getType
-
setType
-
getDriverClassName
Return the configured driver ornull
if none was configured.- Returns:
- the configured driver
- See Also:
-
setDriverClassName
-
determineDriverClassName
Determine the driver to use based on this configuration and the environment.- Returns:
- the driver to use
- Since:
- 1.4.0
-
getUrl
Return the configured url ornull
if none was configured.- Returns:
- the configured url
- See Also:
-
setUrl
-
determineUrl
Determine the url to use based on this configuration and the environment.- Returns:
- the url to use
- Since:
- 1.4.0
-
determineDatabaseName
Determine the name to used based on this configuration.- Returns:
- the database name to use or
null
- Since:
- 2.0.0
-
getUsername
Return the configured username ornull
if none was configured.- Returns:
- the configured username
- See Also:
-
setUsername
-
determineUsername
Determine the username to use based on this configuration and the environment.- Returns:
- the username to use
- Since:
- 1.4.0
-
getPassword
Return the configured password ornull
if none was configured.- Returns:
- the configured password
- See Also:
-
setPassword
-
determinePassword
Determine the password to use based on this configuration and the environment.- Returns:
- the password to use
- Since:
- 1.4.0
-
getJndiName
-
setJndiName
Allows the DataSource to be managed by the container and obtained through JNDI. TheURL
,driverClassName
,username
andpassword
fields will be ignored when using JNDI lookups.- Parameters:
jndiName
- the JNDI name
-
getEmbeddedDatabaseConnection
-
setEmbeddedDatabaseConnection
-
getClassLoader
-
getXa
-
setXa
-