Spring boot - disable Liquibase at startup
Solution 1
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
Solution 2
Add liquibase.enabled=false
in your application.properties file
But if you don't want to use liquibase from application anymore, remove liquibase starter altogether from pom.
Solution 3
If you see on the LiquibaseProperties, there is a prefix like
prefix = "spring.liquibase"
So, My suggestion is to use
spring.liquibase.enabled=false
It solved my problem with spring boot 2.0.0.RC1
Solution 4
I faced an issue where I wasn't able to disable Liquibase from properties for some reason, so this is how I disabled Liquibase with @Bean
annotation:
@Bean
public SpringLiquibase liquibase() {
SpringLiquibase liquibase = new SpringLiquibase();
liquibase.setShouldRun(false);
return liquibase;
}
Solution 5
There is one more programmatic approach.
@EnableAutoConfiguration(exclude = LiquibaseAutoConfiguration.class)
on Application main class
Gravian
Updated on September 11, 2021Comments
-
Gravian over 2 years
I want to have Liquibase configured with my Spring Boot application, so I added dependencies to
pom.xml
and set the path tomaster.xml
inapplication.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? -
Kevin Vasko over 7 yearsThe problem with this is that when spring boot finds liquibase on the classpath it will try to execute on startup afaik.
-
Cèsar over 7 yearsThat's why you have to remove the liquibase starter, or any direct liquibase dependency if you added any. If you only have the liquibase maven plugin, liquibase is not in the application classpath.
-
TOUDIdel almost 5 yearsAfter this I've received
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'liquibase' available
-
David H almost 4 yearsThis worked for me. It is the only solution that makes a SpringLiquibase bean available for autowiring without running on startup. Remember to put it in a @Configuration class.
-
TJReinert almost 3 yearsThis property was migrated to
spring.liquibase.enabled
. -
Codigo Morsa almost 2 yearsspring.liquibase.enabled=false solved my problem too Spring 2.7.1