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
-
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
(ResourceLoader resourceLoader)
-
Constructor Details
-
AbstractScriptDatabaseInitializer
Creates a newAbstractScriptDatabaseInitializer
that will initialize the database using the given settings.- Parameters:
settings
- initialization settings
-
-
Method Details
-
setResourceLoader
- Specified by:
setResourceLoader
in interfaceResourceLoaderAware
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- 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
-