Search code examples
spring-bootliquibase

Liquibase unable to process change log file path from classpath


My spring boot is successfully able to run my liquibase migration with classpath: protocol but when I run mvn liquibase:update it is giving this error:

Caused by: java.nio.file.InvalidPathException: Illegal char <:> at index 9: classpath:/db/changelog/db.changelog-master.yaml at sun.nio.fs.WindowsPathParser.normalize (WindowsPathParser.java:182)

One more issue is that no matter what value I provide to -Dspring.liquibase.change-log or -Dliquibase.change-log or -Dliquibase.changeLog or -Dspring.liquibase.changeLog the location of the classpath always revert back to same value value classpath:/db/changelog/db.changelog-master.yaml which lands in same error

Caused by: java.nio.file.InvalidPathExceptionIllegal char <:> at index 9:

Below is how my application.yml looks like:

spring:
  liquibase:
    enabled: true
    default-schema: dbo
    drop-first: false
    change-log: classpath:db/changelog/db.changelog-master.yaml
datasource:
    url: jdbc:sqlserver://localhost\\SQLEXPRESS:1433;..... (more lines)

This is how the changelog looks like:

databaseChangeLog:

  - include:
      file: /db/changelog/001-changelog-1.0.sql

  - changeSet:
      id: 3
      author: amitthakur
      changes:
        - sqlFile:
            path: db/changelog/001-create-table-user.sql
            dbms: mssql
            relativeToChangelogFile: false

Solution

  • This is what worked for running this app with Maven. I had to provide the -Dliquibase.changeLogFile path to mvn command:

    mvn liquibase:rollback -Dliquibase.changeLogFile=/c/Projects/github/amitthk/myapp-db-updates/src/main/resources/db/changelog/db.changelog-master.yaml -Dliquibase.rollbackCount=1 -Dliquibase.rollbackId=8