Skip to content

Error creating bean with name ‘liquibase’ in Spring Boot App

I have difficulties with adding Liquibase to my existing Spring Boot application.

I added the necessary dependency in pom.xml. Then I have added an empty changelog-master.xml file Here is the code:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog

http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd”>

But when I run the program I got an exception:

Error creating bean with name ‘liquibase’ defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is liquibase.exception.ChangeLogParseException: Error Reading Migration File: class path resource [db/changelog/changelog-master.xml] cannot be resolved to URL because it does not exist

Could anyone suggest some actions?

Answer

you should add path to your changelog file in application.yml

for example:

spring:
  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.xml

and you should create valid empty changelog:

<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">


</databaseChangeLog>