【问题标题】:Liquibase failed to start because no changelog could be found at 'Migration File: class pathLiquibase 无法启动,因为在“迁移文件:类路径”中找不到更改日志
【发布时间】:2021-10-23 06:37:54
【问题描述】:

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

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

项目结构:

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>

【问题讨论】:

  • 它适用于我。告诉我:你是如何尝试运行这个应用程序的?使用 Intellij IDEA 运行不是最好的方法,只有 CLI 命令。

标签: spring-boot maven liquibase


【解决方案1】:

根据您发布的文件树,我相信您的配置有错误:

change-log: classpath:db/changelog/dbchangelog.xml

应该是: change-log: classpath:db.changelog/dbchangelog.xml

【讨论】:

    猜你喜欢
    • 2020-02-12
    • 2015-01-27
    • 2018-12-14
    • 2017-06-18
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 2020-01-28
    • 2018-03-05
    相关资源
    最近更新 更多