Class AbstractScriptDatabaseInitializer

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

public abstract class AbstractScriptDatabaseInitializer extends Object implements ResourceLoaderAware, InitializingBean
Base class for an InitializingBean that performs SQL database initialization using schema (DDL) and data (DML) scripts.
Since:
2.5.0
Author:
Andy Wilkinson
  • Constructor Details

  • Method Details

    • setResourceLoader

      public void setResourceLoader(ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface ResourceLoaderAware
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface InitializingBean
      Throws:
      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(AbstractScriptDatabaseInitializer.Scripts scripts)
      Initialize the database by running the given scripts.
      Parameters:
      scripts - the scripts to run
      Since:
      3.0.0