spring-boot - Liquibase 无法启动,因为在“迁移文件 : class path”中找不到更改日志

标签 spring-boot maven liquibase

当我启动我的应用程序时,它失败并显示此消息,指出更改日志文件的类路径不存在:

Description:

Liquibase failed to start because no changelog could be found at 'Migration File: class path resource [db/changelog/dbchangelog.xml] cannot be resolved to URL because it does not exist'.

Action:

Make sure a Liquibase changelog is present at the configured path.

看起来我在 application.yaml 中有正确的类路径,所以我不知道为什么它说它不存在。

Hee 是 application.yaml 中的类路径

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/db_product
    username: user
    password: password
    driver-class-name: com.mysql.cj.jdbc.Driver
  jpa:
    hibernate.ddl-auto: none
    database-platform: org.hibernate.dialect.MySQLDialect
    show-sql: true
  liquibase:
    change-log: classpath:db/changelog/dbchangelog.xml
    enabled: true

项目结构:

enter image description here

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.9</version>
        <relativePath/>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <properties>
        <java.version>1.8</java.version>
        <mysql-connector-java.version>8.0.25</mysql-connector-java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${mysql-connector-java.version}</version>
        </dependency>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
        </dependency>
        <!-- another dependencies -->
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

最佳答案

根据您发布的文件树,我认为您的配置有误:

更改日志:classpath:db/changelog/dbchangelog.xml

应该是: 更改日志:类路径:db.changelog/dbchangelog.xml

关于spring-boot - Liquibase 无法启动,因为在“迁移文件 : class path”中找不到更改日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68883660/

相关文章:

java - 如何在 Spring-Shell 中屏蔽输入字符串

java - 如何使用 Maven 调用程序以编程方式设置 Artifact ID 和其他信息

java - 如何在 Maven 的本地项目中安装依赖项?

java - 如何为JAXB创建的java文件创建jar?

liquibase - 如何更新现有的变更集

liquibase - Liquibase插入具有多个ID的计算值

grails - Grails数据库迁移失败,并出现LiquibaseException

Spring,跳过(空)配置文件

java.lang.StackOverflowError ManyToMany : MapStruct - Spring Boot - Hibernate

spring-boot - 在 Spring Boot REST API 中上传文件