5

When I start my application it fails with this message saying that the classpath for the changelog file does not exist:

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.

It looks like I have the correct classpath in application.yaml so I have no idea why it is saying that it doesn't exist.

Hee is the classpath in the 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

Project structure:

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>
Dmitry Rakovets
  • 557
  • 1
  • 6
  • 15
Clancinio
  • 734
  • 6
  • 21
  • 40
  • It works for me correctly . Tell me: how are you trying to run this application? Running with Intellij IDEA is not best way, only CLI command. – Dmitry Rakovets Aug 23 '21 at 02:54

2 Answers2

7

According to the file tree you've posted, I believe you have an error in your configuration:

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

It should be: change-log: classpath:db.changelog/dbchangelog.xml

htshame
  • 6,599
  • 5
  • 36
  • 56
0

Add below into application.properties file. spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml

Ashok Parmar
  • 336
  • 4
  • 4