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 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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Scripts to be used to initialize the database. -
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a newAbstractScriptDatabaseInitializer
that will initialize the database using the given settings. -
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
Initializes the database by applying schema and data scripts.protected boolean
Returns whether the database that is to be initialized is embedded.protected abstract void
Initialize the database by running the givenscripts
.void
setResourceLoader
(org.springframework.core.io.ResourceLoader resourceLoader)
-
Constructor Details
-
AbstractScriptDatabaseInitializer
Creates a newAbstractScriptDatabaseInitializer
that will initialize the database using the given settings.- Parameters:
settings
- initialization settings
-
-
Method Details
-
setResourceLoader
public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader) - Specified by:
setResourceLoader
in interfaceorg.springframework.context.ResourceLoaderAware
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.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, otherwisefalse
-
isEmbeddedDatabase
protected boolean isEmbeddedDatabase()Returns whether the database that is to be initialized is embedded.- Returns:
true
if the database is embedded, otherwisefalse
- Since:
- 2.5.1
-
runScripts
Initialize the database by running the givenscripts
.- Parameters:
scripts
- the scripts to run- Since:
- 3.0.0
-