繁体   English   中英

在 Spring 引导应用程序中创建名为“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">

但是当我运行程序时,我遇到了一个异常:

在 class 路径资源 [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class] 中定义名称为“liquibase”的 bean 创建错误:调用 init 方法失败; 嵌套异常是 liquibase.exception.ChangeLogParseException: Error Reading Migration File: 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM