I want to have Liquibase configured with my Spring Boot application, so I added dependencies to pom.xml
and set the path to master.xml
in application.properties
. This works fine and Spring Boot runs Liquibase at startup. The problem is that now I want to run Liquibase manually, not at startup of application. Should I completely disable auto-configuration for Liquibase or can I use it and only disable running evaluations at startup?
54
votes
6 Answers
83
votes
The relevant property name has changed between Spring versions:
For Spring 4.x.x: the
liquibase.enabled=false
application property disables Liquibase.For Spring 5.x.x: the
spring.liquibase.enabled=false
application property disables Liquibase.
P.S. And for Flyway:
Spring 4.x.x:
flyway.enabled=false
Spring 5.x.x:
spring.flyway.enabled=false
35
votes
27
votes
12
votes
7
votes
3
votes
If you want to run Liquibase manually, you could use the liquibase maven plugin. Just add something like this to your pom.xml:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.version}</version>
<configuration>
<changeLogFile>src/main/liquibase/master.xml</changeLogFile>
<propertyFile>src/main/liquibase/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
You can take a look at the plugin documentation for the configuration details.
And don't use the liquibase support from Spring Boot, as it is only meant to be used in runtime. Just remove the liquibase starter and/or any related dependencies as you'll only need the maven plugin.