Class DataSourceScriptDatabaseInitializer
java.lang.Object
org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer
org.springframework.boot.jdbc.init.DataSourceScriptDatabaseInitializer
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ResourceLoaderAware
InitializingBean
that performs DataSource
initialization using schema
(DDL) and data (DML) scripts.- Since:
- 2.5.0
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer
AbstractScriptDatabaseInitializer.Scripts
-
Constructor Summary
ConstructorDescriptionDataSourceScriptDatabaseInitializer
(DataSource dataSource, DatabaseInitializationSettings settings) Creates a newDataSourceScriptDatabaseInitializer
that will initialize the givenDataSource
using the given settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
customize
(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator populator) Customize theResourceDatabasePopulator
.protected final DataSource
Returns theDataSource
that will be initialized.protected boolean
Returns whether the database that is to be initialized is embedded.protected void
Initialize the database by running the givenscripts
.Methods inherited from class org.springframework.boot.sql.init.AbstractScriptDatabaseInitializer
afterPropertiesSet, initializeDatabase, setResourceLoader
-
Constructor Details
-
DataSourceScriptDatabaseInitializer
public DataSourceScriptDatabaseInitializer(DataSource dataSource, DatabaseInitializationSettings settings) Creates a newDataSourceScriptDatabaseInitializer
that will initialize the givenDataSource
using the given settings.- Parameters:
dataSource
- data source to initializesettings
- the initialization settings
-
-
Method Details
-
getDataSource
Returns theDataSource
that will be initialized.- Returns:
- the initialization data source
-
isEmbeddedDatabase
protected boolean isEmbeddedDatabase()Description copied from class:AbstractScriptDatabaseInitializer
Returns whether the database that is to be initialized is embedded.- Overrides:
isEmbeddedDatabase
in classAbstractScriptDatabaseInitializer
- Returns:
true
if the database is embedded, otherwisefalse
-
runScripts
Description copied from class:AbstractScriptDatabaseInitializer
Initialize the database by running the givenscripts
.- Specified by:
runScripts
in classAbstractScriptDatabaseInitializer
- Parameters:
scripts
- the scripts to run
-
customize
protected void customize(org.springframework.jdbc.datasource.init.ResourceDatabasePopulator populator) Customize theResourceDatabasePopulator
.- Parameters:
populator
- the configured database populator- Since:
- 2.6.2
-