Class DataSourceProperties
java.lang.Object
org.springframework.boot.autoconfigure.jdbc.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:
- 1.1.0
- Author:
- Dave Syer, Maciej Walkowiak, Stephane Nicoll, Benedikt Ritter, EddĂș MelĂ©ndez, Scott Frederick
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classXA Specific datasource settings. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidDetermine 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 ornullif none was configured.getName()Return the configured password ornullif none was configured.Class<? extends DataSource>getType()getUrl()Return the configured url ornullif none was configured.Return the configured username ornullif none was configured.getXa()Initialize aDataSourceBuilderwith the state of this instance.booleanvoidsetBeanClassLoader(ClassLoader classLoader) voidsetDriverClassName(String driverClassName) voidsetEmbeddedDatabaseConnection(EmbeddedDatabaseConnection embeddedDatabaseConnection) voidsetGenerateUniqueName(boolean generateUniqueName) voidsetJndiName(String jndiName) Allows the DataSource to be managed by the container and obtained through JNDI.voidvoidsetPassword(String password) voidsetType(Class<? extends DataSource> type) voidvoidsetUsername(String username) void
-
Constructor Details
-
DataSourceProperties
public DataSourceProperties()
-
-
Method Details
-
setBeanClassLoader
- Specified by:
setBeanClassLoaderin interfaceBeanClassLoaderAware
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-
initializeDataSourceBuilder
Initialize aDataSourceBuilderwith the state of this instance.- Returns:
- a
DataSourceBuilderinitialized 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 ornullif 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 ornullif 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 ornullif 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 ornullif 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,usernameandpasswordfields will be ignored when using JNDI lookups.- Parameters:
jndiName- the JNDI name
-
getEmbeddedDatabaseConnection
-
setEmbeddedDatabaseConnection
-
getClassLoader
-
getXa
-
setXa
-