3
votes

My liquibase maven plugin configuration is:

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>${liquibase.version}</version>
    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${postgresql.version}</version>
        </dependency>
    </dependencies>
    <configuration>
        <skip>${liquibase.skip}</skip>
        <propertyFileWillOverride>true</propertyFileWillOverride>
        <changeLogFile>src/main/resources/db.changelog-master.xml</changeLogFile>
        <propertyFile>src/main/resources/${project.artifactId}-liquibase.properties</propertyFile>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
    </configuration>
</plugin>

I'm getting this error message when I start my spring-boot:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)

I don't quite figure out why liquibase is trying to pick this changelog file db/changelog/db.changelog-master.yaml when I've set:

<changeLogFile>src/main/resources/db.changelog-master.xml</changeLogFile>

My 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">

    <changeSet author="ddd" id="tdev-forum-service-1"
        context="dev, int, rel" labels="tdev-forum-service">
        <createTable tableName="TDEV_FORUM" remarks="Discussions about shared code">
            <column name="FORUM_ID" type="VARCHAR(36)">
                <constraints nullable="false" primaryKey="true" />
            </column>

            <column name="TOPIC_NAME" type="VARCHAR(128)">
                <constraints nullable="false" />
            </column>

            <column name="TOPIC_CATEGORY" type="VARCHAR(32)">
                <constraints nullable="false" />
            </column>

            <column name="SOURCE_CODE_ITEM_ID" type="VARCHAR(36)">
                <constraints nullable="false" />
            </column>

        </createTable>

    </changeSet>



    <changeSet author="ddd" id="tdev-forum-service-2"
        context="dev" labels="tdev-forum-service">

        <insert tableName="TDEV_FORUM">
            <column name="FORUM_ID" value="36afbfcd-969d-4a0e-9d63-25bd9d4e8f6b" />
            <column name="TOPIC_NAME" value="How to read a text file using streams" />
            <column name="TOPIC_CATEGORY" value="I/O Streams" />
            <column name="SOURCE_CODE_ITEM_ID" value="4600eab2-c375-4b99-97ab-9670ed93f861" />
        </insert>

        <rollback>
            <delete tableName="TDEV_FORUM">
                <where>FORUM_ID='36afbfcd-969d-4a0e-9d63-25bd9d4e8f6b'</where>
            </delete>
        </rollback>
    </changeSet>



    <changeSet author="ddd" id="tdev-forum-service-3"
        context="dev, int, rel" labels="tdev-forum-service">
        <createTable tableName="TDEV_FORUM_MESSAGE" remarks="Messages from developers">
            <column name="MESSAGE_ID" type="VARCHAR(36)">
                <constraints nullable="false" primaryKey="true" />
            </column>

            <column name="FORUM_ID" type="VARCHAR(36)">
                <constraints nullable="false" />
            </column>

            <column name="CONTENT" type="TEXT">
                <constraints nullable="true" />
            </column>

        </createTable>

    </changeSet>

    <changeSet author="sdd" id="tdev-forum-service-4"
        context="dev, int, rel" labels="tdev-forum-service">

        <addForeignKeyConstraint baseColumnNames="FORUM_ID"
            baseTableName="TDEV_FORUM_MESSAGE" constraintName="FK_MESSAGE_FORUM"
            deferrable="true" initiallyDeferred="true" onDelete="CASCADE"
            onUpdate="RESTRICT" referencedColumnNames="FORUM_ID"
            referencedTableName="TDEV_FORUM" />
    </changeSet>

</databaseChangeLog>
1

1 Answers

12
votes

By default Spring Boot expects you to use yaml formatted changeset files instead of xml. And also the location db/changelog/db.changelog-master.yaml seems to be a default value.

So I guess the overwriting of these defaults do not work in your case.

Here is documentation on how to overwrite this in Spring Boot.

As far as I can see (I do not use Spring Boot) you need to set the property spring.liquibase.change-log in the application.properties.