gpt4 book ai didi

java - Liquibase Maven : Cannot find changelog location when spring-boot starts

转载 作者:行者123 更新时间:2023-12-01 14:06:13 25 4
gpt4 key购买 nike

我的 liquibase maven 插件配置是:

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

当我启动 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)



我不太明白为什么 liquibase 试图选择这个更新日志文件 db/changelog/db.changelog-master.yaml当我设置:
<changeLogFile>src/main/resources/db.changelog-master.xml</changeLogFile>

我的更新日志:
<?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>

最佳答案

默认情况下,Spring Boot 期望您使用 yaml 格式的变更集文件而不是 xml。
还有位置db/changelog/db.changelog-master.yaml好像是default value .

所以我猜这些默认值的覆盖在你的情况下不起作用。

这是documentation关于如何在 Spring Boot 中覆盖它。

据我所知(我不使用 Spring Boot)你需要设置属性 spring.liquibase.change-logapplication.properties .

关于java - Liquibase Maven : Cannot find changelog location when spring-boot starts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51204132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com