org.springframework.boot.sql.init

Class AbstractScriptDatabaseInitializer

  • java.lang.Object
    • org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer
  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ResourceLoaderAware
    Direct Known Subclasses:
    DataSourceScriptDatabaseInitializer, R2dbcScriptDatabaseInitializer


    public abstract class AbstractScriptDatabaseInitializer
    extends java.lang.Object
    implements org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.InitializingBean
    Base class for an InitializingBean that performs SQL database initialization using schema (DDL) and data (DML) scripts.
    Since:
    2.5.0
    • Method Detail

      • setResourceLoader

        public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
        Specified by:
        setResourceLoader in interface org.springframework.context.ResourceLoaderAware
      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws java.lang.Exception
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Throws:
        java.lang.Exception
      • initializeDatabase

        public boolean initializeDatabase()
        Initializes the database by applying schema and data scripts.
        Returns:
        true if one or more scripts were applied to the database, otherwise false
      • isEmbeddedDatabase

        protected boolean isEmbeddedDatabase()
        Returns whether the database that is to be initialized is embedded.
        Returns:
        true if the database is embedded, otherwise false
        Since:
        2.5.1
      • runScripts

        protected abstract void runScripts(java.util.List<org.springframework.core.io.Resource> resources,
                                           boolean continueOnError,
                                           java.lang.String separator,
                                           java.nio.charset.Charset encoding)