类 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()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
afterPropertiesSet()
Use the database populator to set up the database.void
destroy()
Use the database cleaner to clean up the database.void
setDatabaseCleaner(DatabasePopulator databaseCleaner)
Set theDatabasePopulator
to execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.void
setDatabasePopulator(DatabasePopulator databasePopulator)
Set theDatabasePopulator
to execute during the bean initialization phase.void
setDataSource(DataSource dataSource)
TheDataSource
for the database to populate when this component is initialized and to clean up when this component is shut down.void
setEnabled(boolean enabled)
Flag to explicitly enable or disable the database populator and database cleaner.
构造器详细资料
DataSourceInitializer
public DataSourceInitializer()
方法详细资料
setDataSource
public void setDataSource(DataSource dataSource)
TheDataSource
for 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 theDatabasePopulator
to execute during the bean initialization phase.- 参数:
databasePopulator
- theDatabasePopulator
to use during initialization- 另请参阅:
setDatabaseCleaner(org.springframework.jdbc.datasource.init.DatabasePopulator)
setDatabaseCleaner
public void setDatabaseCleaner(DatabasePopulator databaseCleaner)
Set theDatabasePopulator
to execute during the bean destruction phase, cleaning up the database and leaving it in a known state for others.- 参数:
databaseCleaner
- theDatabasePopulator
to 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
-true
if 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