LiquiBase
YAML
database migration
error resolution
classpath issue

LiquiBase problem , class path resource db/changelog/db.changelog-master.yaml cannot be resolved to URL because it does not exist

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

The error "class path resource db/changelog/db.changelog-master.yaml cannot be resolved to URL because it does not exist" means Spring Boot cannot find your Liquibase changelog file at the expected classpath location. This typically happens because the file is in the wrong directory, has a wrong file extension, or the spring.liquibase.change-log property points to a non-existent path. The fix is to ensure the file exists at the exact path that Liquibase is configured to look for.

The Error

 
Caused by: java.io.FileNotFoundException: class path resource
[db/changelog/db.changelog-master.yaml] cannot be resolved to URL
because it does not exist

This error occurs during Spring Boot startup when Liquibase tries to read the master changelog file.

Fix 1: Create the Changelog File in the Correct Location

The default path that Spring Boot expects is src/main/resources/db/changelog/db.changelog-master.yaml:

 
1your-project/
2├── src/
3│   └── main/
4│       └── resources/
5│           └── db/
6│               └── changelog/
7│                   ├── db.changelog-master.yamlThis file
8│                   └── changes/
9│                       ├── 001-create-users.yaml
10│                       └── 002-add-email-column.yaml

Create the master changelog:

yaml
1# src/main/resources/db/changelog/db.changelog-master.yaml
2databaseChangeLog:
3  - include:
4      file: db/changelog/changes/001-create-users.yaml
5  - include:
6      file: db/changelog/changes/002-add-email-column.yaml

Fix 2: Match the Configured Path

If you use a custom path in application.properties or application.yml, the file must exist at that path:

properties
# application.properties
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.yaml
yaml
1# application.yml
2spring:
3  liquibase:
4    change-log: classpath:db/changelog/db.changelog-master.yaml

If your file uses a different extension (.yml instead of .yaml), update the configuration to match:

properties
# If your file is db.changelog-master.yml (not .yaml)
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.yml

Fix 3: Use XML or SQL Format Instead

Liquibase supports multiple changelog formats. If you prefer XML:

properties
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml
xml
1<!-- src/main/resources/db/changelog/db.changelog-master.xml -->
2<?xml version="1.0" encoding="UTF-8"?>
3<databaseChangeLog
4    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
7        http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
8
9    <include file="db/changelog/changes/001-create-users.xml"/>
10</databaseChangeLog>

Fix 4: Verify Build Output

The file must be present in the compiled output. Check the build directory:

bash
1# Maven
2ls target/classes/db/changelog/
3
4# Gradle
5ls build/resources/main/db/changelog/

If the directory is empty, the file is not being copied during the build. Verify your build tool configuration:

xml
1<!-- Maven: pom.xml — resources are in src/main/resources by default -->
2<build>
3    <resources>
4        <resource>
5            <directory>src/main/resources</directory>
6            <includes>
7                <include>**/*.yaml</include>
8                <include>**/*.yml</include>
9                <include>**/*.xml</include>
10            </includes>
11        </resource>
12    </resources>
13</build>
groovy
1// Gradle: build.gradle — resources are included by default
2// But if you customized sourceSets, ensure resources are included:
3sourceSets {
4    main {
5        resources {
6            srcDir 'src/main/resources'
7        }
8    }
9}

Fix 5: Disable Liquibase (If Not Needed)

If you are not using Liquibase and it was pulled in as a transitive dependency:

properties
# application.properties
spring.liquibase.enabled=false

Or exclude the auto-configuration:

java
1@SpringBootApplication(exclude = {LiquibaseAutoConfiguration.class})
2public class MyApplication {
3    public static void main(String[] args) {
4        SpringApplication.run(MyApplication.class, args);
5    }
6}

Common Pitfalls

  • File extension mismatch: Liquibase distinguishes between .yaml, .yml, .xml, and .sql. If the config says .yaml but the file is .yml, it will not be found. The extension in the property must exactly match the actual file name.
  • Wrong directory in multi-module projects: In Maven/Gradle multi-module projects, each module has its own src/main/resources. The changelog must be in the resources directory of the module that contains the Spring Boot application class, not a sibling module.
  • IDE not copying resources: Some IDEs cache the build output. After creating the changelog file, run a clean build (mvn clean compile or gradle clean build) to ensure the file is copied to the output directory.
  • Using file: prefix instead of classpath:: The file: prefix looks for an absolute path on the filesystem, not in the classpath. Use classpath: for files in src/main/resources.
  • Liquibase YAML parsing errors: If the file exists but is malformed YAML (wrong indentation, tabs instead of spaces), Liquibase throws a different error. Validate your YAML syntax separately if the "does not exist" error is resolved but a new error appears.

Summary

  • The default changelog path is src/main/resources/db/changelog/db.changelog-master.yaml
  • Ensure spring.liquibase.change-log matches the actual file path and extension exactly
  • Check the compiled output directory (target/classes/ or build/resources/main/) to verify the file is included in the build
  • Use spring.liquibase.enabled=false to disable Liquibase if it was added as an unwanted transitive dependency
  • Run a clean build after creating or moving changelog files to clear stale caches

Course illustration
Course illustration