Spring boot - disable Liquibase at startup

63,101

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

Reference

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

Share:
63,101
Gravian
Author by

Gravian

Updated on September 11, 2021

Comments

  • Gravian
    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 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?

  • Kevin Vasko
    Kevin Vasko over 7 years
    The problem with this is that when spring boot finds liquibase on the classpath it will try to execute on startup afaik.
  • Cèsar
    Cèsar over 7 years
    That'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
    TOUDIdel almost 5 years
    After this I've received org.springframework.beans.factory.NoSuchBeanDefinitionExcept‌​ion: No bean named 'liquibase' available
  • David H
    David H almost 4 years
    This 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
    TJReinert almost 3 years
    This property was migrated to spring.liquibase.enabled.
  • Codigo Morsa
    Codigo Morsa almost 2 years
    spring.liquibase.enabled=false solved my problem too Spring 2.7.1