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
  • 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 String getName()
    • setName

      public void setName(String name)
    • getType

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

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

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

      public void setDriverClassName(String driverClassName)
    • determineDriverClassName

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

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

      public void setUrl(String url)
    • determineUrl

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

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

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

      public void setUsername(String username)
    • determineUsername

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

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

      public void setPassword(String password)
    • determinePassword

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

      public String getJndiName()
    • setJndiName

      public void setJndiName(String jndiName)
      Allows the DataSource to be managed by the container and obtained via 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)