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
  • Constructor Details

    • DataSourceProperties

      public DataSourceProperties()
  • Method Details

    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface BeanClassLoaderAware
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface InitializingBean
      Throws:
      Exception
    • initializeDataSourceBuilder

      public DataSourceBuilder<?> initializeDataSourceBuilder()
      Initialize a DataSourceBuilder 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

      public @Nullable String getName()
    • setName

      public void setName(@Nullable String name)
    • getType

      public @Nullable Class<? extends DataSource> getType()
    • setType

      public void setType(@Nullable Class<? extends DataSource> type)
    • getDriverClassName

      public @Nullable String getDriverClassName()
      Return the configured driver or null if none was configured.
      Returns:
      the configured driver
      See Also:
    • setDriverClassName

      public void setDriverClassName(@Nullable String driverClassName)
    • determineDriverClassName

      public String determineDriverClassName()
      Determine the driver to use based on this configuration and the environment.
      Returns:
      the driver to use
    • getUrl

      public @Nullable String getUrl()
      Return the configured url or null if none was configured.
      Returns:
      the configured url
      See Also:
    • setUrl

      public void setUrl(@Nullable String url)
    • determineUrl

      public String determineUrl()
      Determine the url to use based on this configuration and the environment.
      Returns:
      the url to use
    • determineDatabaseName

      public @Nullable String determineDatabaseName()
      Determine the name to used based on this configuration.
      Returns:
      the database name to use or null
    • getUsername

      public @Nullable String getUsername()
      Return the configured username or null if none was configured.
      Returns:
      the configured username
      See Also:
    • setUsername

      public void setUsername(@Nullable String username)
    • determineUsername

      public @Nullable String determineUsername()
      Determine the username to use based on this configuration and the environment.
      Returns:
      the username to use
    • getPassword

      public @Nullable String getPassword()
      Return the configured password or null if none was configured.
      Returns:
      the configured password
      See Also:
    • setPassword

      public void setPassword(@Nullable String password)
    • determinePassword

      public @Nullable String determinePassword()
      Determine the password to use based on this configuration and the environment.
      Returns:
      the password to use
    • getJndiName

      public @Nullable String getJndiName()
    • setJndiName

      public void setJndiName(@Nullable String jndiName)
      Allows the DataSource to be managed by the container and obtained through JNDI. The URL, driverClassName, username and password fields will be ignored when using JNDI lookups.
      Parameters:
      jndiName - the JNDI name
    • getEmbeddedDatabaseConnection

      public EmbeddedDatabaseConnection getEmbeddedDatabaseConnection()
    • setEmbeddedDatabaseConnection

      public void setEmbeddedDatabaseConnection(EmbeddedDatabaseConnection embeddedDatabaseConnection)
    • getClassLoader

      public ClassLoader getClassLoader()
    • getXa

      public DataSourceProperties.Xa getXa()
    • setXa

      public void setXa(DataSourceProperties.Xa xa)