Package liquibase.integration.spring
Class SpringLiquibase
java.lang.Object
liquibase.integration.spring.SpringLiquibase
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ResourceLoaderAware
public class SpringLiquibase
extends Object
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ResourceLoaderAware
A Spring-ified wrapper for Liquibase.
Example Configuration:
This Spring configuration example will cause liquibase to run automatically when the Spring context is
initialized. It will load
db-changelog.xml from the classpath and apply it against
myDataSource.
<bean id="myLiquibase"
class="liquibase.spring.SpringLiquibase"
>
<property name="dataSource" ref="myDataSource" />
<property name="changeLog" value="classpath:db-changelog.xml" />
</bean>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Booleanprotected Stringprotected Stringprotected booleanprotected Stringprotected Customizer<Liquibase>protected Stringprotected Stringprotected DataSourceprotected Stringprotected booleanprotected Stringprotected Stringprotected Stringprotected Stringprotected final Loggerprotected org.springframework.core.io.ResourceLoaderprotected Fileprotected booleanprotected UpdateSummaryEnumprotected UpdateSummaryOutputEnumprotected Stringprotected booleanprotected UIServiceEnum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidExecuted automatically when the bean is initialized.protected DatabasecreateDatabase(Connection c, ResourceAccessor resourceAccessor) Subclasses may override this method to modify the database settings, such as the default schema, before returning the database object.protected Liquibaseprotected SpringResourceAccessorCreate a new resourceOpener.Gets the Spring-name of this instance.Returns a Resource that is able to resolve to a file or classpath resource.The DataSource that liquibase will use to perform the migration.Deprecated.booleanReturns whether a rollback should be tested at update time or not.protected voidperformUpdate(Liquibase liquibase) voidsetBeanName(String name) Spring sets this automatically to the instance's configured bean name.voidsetChangeLog(String dataModel) Sets a Spring Resource that is able to resolve to a file or classpath resource.voidsetChangeLogParameters(Map<String, String> parameters) voidsetDataSource(DataSource dataSource) The DataSource that liquibase will use to perform the migration.voidDeprecated.use#setLabelFilter(String)voidsetShowSummaryOutput(UpdateSummaryOutputEnum showSummaryOutput) voidsetTestRollbackOnUpdate(boolean testRollbackOnUpdate) If testRollbackOnUpdate is set to true a rollback will be tested at update time.voidsetUiService(UIServiceEnum uiService) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.context.ResourceLoaderAware
setResourceLoader
-
Field Details
-
log
-
beanName
-
resourceLoader
protected org.springframework.core.io.ResourceLoader resourceLoader -
dataSource
-
changeLog
-
contexts
-
labelFilter
-
tag
-
parameters
-
defaultSchema
-
liquibaseSchema
-
databaseChangeLogTable
-
databaseChangeLogLockTable
-
liquibaseTablespace
-
dropFirst
protected boolean dropFirst -
clearCheckSums
protected boolean clearCheckSums -
licenseKey
-
analyticsEnabled
-
shouldRun
protected boolean shouldRun -
rollbackFile
-
showSummary
-
showSummaryOutput
-
testRollbackOnUpdate
protected boolean testRollbackOnUpdate -
uiService
-
customizer
-
-
Constructor Details
-
SpringLiquibase
public SpringLiquibase()
-
-
Method Details
-
getDatabaseProductName
- Throws:
DatabaseException
-
getDataSource
The DataSource that liquibase will use to perform the migration. -
setDataSource
The DataSource that liquibase will use to perform the migration. -
getChangeLog
Returns a Resource that is able to resolve to a file or classpath resource. -
setChangeLog
Sets a Spring Resource that is able to resolve to a file or classpath resource. An example might beclasspath:db-changelog.xml. -
getLabels
Deprecated.use#getLabelFilter() -
setLabels
Deprecated.use#setLabelFilter(String) -
isTestRollbackOnUpdate
public boolean isTestRollbackOnUpdate()Returns whether a rollback should be tested at update time or not. -
setTestRollbackOnUpdate
public void setTestRollbackOnUpdate(boolean testRollbackOnUpdate) If testRollbackOnUpdate is set to true a rollback will be tested at update time. For doing so when the update is performed- Parameters:
testRollbackOnUpdate-
-
afterPropertiesSet
Executed automatically when the bean is initialized.- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
LiquibaseException
-
performUpdate
- Throws:
LiquibaseException
-
createLiquibase
- Throws:
LiquibaseException
-
createDatabase
protected Database createDatabase(Connection c, ResourceAccessor resourceAccessor) throws DatabaseException Subclasses may override this method to modify the database settings, such as the default schema, before returning the database object.- Parameters:
c- the connection to the database- Returns:
- a Database implementation retrieved from the
DatabaseFactory - Throws:
DatabaseException- if there is an error retrieving the database implementation
-
setChangeLogParameters
-
createResourceOpener
Create a new resourceOpener. -
getBeanName
Gets the Spring-name of this instance.- Returns:
-
setBeanName
Spring sets this automatically to the instance's configured bean name.- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setShowSummaryOutput
-
setUiService
-
toString
-
#getLabelFilter()