From faaada141692f2270f4bbd5583745862d20617d0 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 1 Aug 2019 15:16:34 -0700 Subject: [PATCH] Remove liquibase check change log location Missing change logs would lead to an exception even if the checkChangeLogLocation was set to false. Spring Boot's check would pass but Liquibase would fail later making this property redundant. Fixes gh-16232 --- .../liquibase/LiquibaseAutoConfiguration.java | 12 ------------ .../liquibase/LiquibaseProperties.java | 13 ------------- .../additional-spring-configuration-metadata.json | 12 +++++++++++- .../asciidoc/appendix-application-properties.adoc | 1 - 4 files changed, 11 insertions(+), 27 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java index c8d1aaf9728..1d3df0dc082 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java @@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.liquibase; import java.util.function.Supplier; -import javax.annotation.PostConstruct; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; @@ -43,13 +42,11 @@ import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.springframework.jdbc.core.JdbcOperations; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations; import org.springframework.orm.jpa.AbstractEntityManagerFactoryBean; import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; -import org.springframework.util.Assert; /** * {@link EnableAutoConfiguration Auto-configuration} for Liquibase. @@ -103,15 +100,6 @@ public class LiquibaseAutoConfiguration { this.liquibaseDataSource = liquibaseDataSource.getIfAvailable(); } - @PostConstruct - public void checkChangelogExists() { - if (this.properties.isCheckChangeLogLocation()) { - Resource resource = this.resourceLoader.getResource(this.properties.getChangeLog()); - Assert.state(resource.exists(), () -> "Cannot find changelog location: " + resource - + " (please add changelog or check your Liquibase " + "configuration)"); - } - } - @Bean public SpringLiquibase liquibase() { SpringLiquibase liquibase = createSpringLiquibase(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java index 6eebb4abac1..2fe7fdf4e93 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java @@ -38,11 +38,6 @@ public class LiquibaseProperties { */ private String changeLog = "classpath:/db/changelog/db.changelog-master.yaml"; - /** - * Whether to check that the change log location exists. - */ - private boolean checkChangeLogLocation = true; - /** * Comma-separated list of runtime contexts to use. */ @@ -128,14 +123,6 @@ public class LiquibaseProperties { this.changeLog = changeLog; } - public boolean isCheckChangeLogLocation() { - return this.checkChangeLogLocation; - } - - public void setCheckChangeLogLocation(boolean checkChangeLogLocation) { - this.checkChangeLogLocation = checkChangeLogLocation; - } - public String getContexts() { return this.contexts; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 5a4d2130777..25a25a02b02 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -976,7 +976,7 @@ "description": "Check the change log location exists.", "defaultValue": true, "deprecation": { - "replacement": "spring.liquibase.check-change-log-location", + "reason": "Liquibase has it's own check that checks if the change log location exists making this property redundant.", "level": "error" } }, @@ -1875,6 +1875,16 @@ "level": "error" } }, + { + "name": "spring.liquibase.check-change-log-location", + "type": "java.lang.Boolean", + "description": "Check the change log location exists.", + "defaultValue": true, + "deprecation": { + "reason": "Liquibase has it's own check that checks if the change log location exists making this property redundant.", + "level": "error" + } + }, { "name": "spring.messages.cache-seconds", "type": "java.lang.Integer", diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 6dc8d0ef168..a78fd45b4f0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -592,7 +592,6 @@ content into your application. Rather, pick only the properties that you need. # LIQUIBASE ({sc-spring-boot-autoconfigure}/liquibase/LiquibaseProperties.{sc-ext}[LiquibaseProperties]) spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path. - spring.liquibase.check-change-log-location=true # Whether to check that the change log location exists. spring.liquibase.contexts= # Comma-separated list of runtime contexts to use. spring.liquibase.database-change-log-lock-table=DATABASECHANGELOGLOCK # Name of table to use for tracking concurrent Liquibase usage. spring.liquibase.database-change-log-table=DATABASECHANGELOG # Name of table to use for tracking change history.