在 Spring Boot App 中创建名称为 'liquibase' 的 bean 时出错

Error creating bean with name 'liquibase' in Spring Boot App

我很难将 Liquibase 添加到我现有的 Spring 启动应用程序。

我在 pom.xml 中添加了必要的依赖项。然后我添加了一个空的 changelog-master.xml 文件 这是代码:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog

http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

但是当我运行程序出现异常时:

创建名称为 'liquibase' 的 bean 在 class 路径资源 [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class] 中定义时出错:调用 init 方法失败;嵌套异常是 liquibase.exception.ChangeLogParseException:读取迁移文件时出错:class 路径资源 [db/changelog/changelog-master.xml] 无法解析为 URL,因为它不存在

有人可以建议一些操作吗?

您应该在 application.yml

中添加更新日志文件的路径

例如:

spring:
  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.xml

并且您应该创建有效的空更新日志:

<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">


</databaseChangeLog>