类 DataSourceInitializer
- java.lang.Object
- org.springframework.jdbc.datasource.init.DataSourceInitializer
- 所有已实现的接口:
DisposableBean,InitializingBean
public class DataSourceInitializer extends Object implements InitializingBean, DisposableBean
- 从以下版本开始:
- 3.0
- 作者:
- Dave Syer, Sam Brannen
- 另请参阅:
DatabasePopulator
构造器概要
构造器 构造器 说明 DataSourceInitializer()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidafterPropertiesSet()Use the database populator to set up the database.voiddestroy()Use the database cleaner to clean up the database.voidsetDatabaseCleaner(DatabasePopulator databaseCleaner)Set theDatabasePopulatorto execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.voidsetDatabasePopulator(DatabasePopulator databasePopulator)Set theDatabasePopulatorto execute during the bean initialization phase.voidsetDataSource(DataSource dataSource)TheDataSourcefor the database to populate when this component is initialized and to clean up when this component is shut down.voidsetEnabled(boolean enabled)Flag to explicitly enable or disable the database populator and database cleaner.
构造器详细资料
DataSourceInitializer
public DataSourceInitializer()
方法详细资料
setDataSource
public void setDataSource(DataSource dataSource)
TheDataSourcefor the database to populate when this component is initialized and to clean up when this component is shut down.This property is mandatory with no default provided.
- 参数:
dataSource- the DataSource
setDatabasePopulator
public void setDatabasePopulator(DatabasePopulator databasePopulator)
Set theDatabasePopulatorto execute during the bean initialization phase.- 参数:
databasePopulator- theDatabasePopulatorto use during initialization- 另请参阅:
setDatabaseCleaner(org.springframework.jdbc.datasource.init.DatabasePopulator)
setDatabaseCleaner
public void setDatabaseCleaner(DatabasePopulator databaseCleaner)
Set theDatabasePopulatorto execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.- 参数:
databaseCleaner- theDatabasePopulatorto use during destruction- 另请参阅:
setDatabasePopulator(org.springframework.jdbc.datasource.init.DatabasePopulator)
setEnabled
public void setEnabled(boolean enabled)
Flag to explicitly enable or disable the database populator and database cleaner.- 参数:
enabled-trueif the database populator and database cleaner should be called on startup and shutdown, respectively
afterPropertiesSet
public void afterPropertiesSet()
Use the database populator to set up the database.- 指定者:
afterPropertiesSet在接口中InitializingBean
destroy
public void destroy()
Use the database cleaner to clean up the database.- 指定者:
destroy在接口中DisposableBean