Class DataSourceProperties
java.lang.Object
org.springframework.boot.jdbc.autoconfigure.DataSourceProperties
- All Implemented Interfaces:
Aware
,BeanClassLoaderAware
,InitializingBean
@ConfigurationProperties("spring.datasource")
public class DataSourceProperties
extends Object
implements BeanClassLoaderAware, InitializingBean
Base class for configuration of a data source.
- Since:
- 4.0.0
- Author:
- Dave Syer, Maciej Walkowiak, Stephane Nicoll, Benedikt Ritter, EddĂș MelĂ©ndez, Scott Frederick
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
XA Specific datasource settings. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
@Nullable String
Determine the name to used based on this configuration.Determine the driver to use based on this configuration and the environment.@Nullable String
Determine the password to use based on this configuration and the environment.Determine the url to use based on this configuration and the environment.@Nullable String
Determine the username to use based on this configuration and the environment.@Nullable String
Return the configured driver ornull
if none was configured.@Nullable String
@Nullable String
getName()
@Nullable String
Return the configured password ornull
if none was configured.@Nullable Class
<? extends DataSource> getType()
@Nullable String
getUrl()
Return the configured url ornull
if none was configured.@Nullable String
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
(@Nullable String driverClassName) void
setEmbeddedDatabaseConnection
(EmbeddedDatabaseConnection embeddedDatabaseConnection) void
setGenerateUniqueName
(boolean generateUniqueName) void
setJndiName
(@Nullable String jndiName) Allows the DataSource to be managed by the container and obtained through JNDI.void
void
setPassword
(@Nullable String password) void
setType
(@Nullable Class<? extends DataSource> type) void
void
setUsername
(@Nullable 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
-
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
-
determineDatabaseName
Determine the name to used based on this configuration.- Returns:
- the database name to use or
null
-
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
-
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
-
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
-