关键词:
【中文标题】Liquibase maven:spring-boot启动时找不到更改日志位置【英文标题】:Liquibase maven: Cannot find changelog location when spring-boot starts 【发布时间】:2018-12-14 16:38:01 【问题描述】:我的 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:创建名为“org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration”的bean时出错:调用init方法失败;嵌套异常是 java.lang.IllegalStateException:找不到更改日志位置:类路径资源 [db/changelog/db.changelog-master.yaml](请添加更改日志或检查您的 Liquibase 配置)
我不太明白为什么在我设置后 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>
【问题讨论】:
【参考方案1】:默认情况下,Spring Boot 期望您使用 yaml 格式的变更集文件而不是 xml。
而且位置db/changelog/db.changelog-master.yaml
似乎是default value。
所以我猜这些默认值的覆盖在你的情况下不起作用。
这里是documentation,关于如何在 Spring Boot 中覆盖它。
据我所知(我不使用 Spring Boot)您需要在 application.properties
中设置属性 spring.liquibase.change-log
。
【讨论】:
Liquibase Maven 无法读取 changeLogFile
】LiquibaseMaven无法读取changeLogFile【英文标题】:LiquibaseMavencan\'treadchangeLogFile【发布时间】:2017-08-1001:11:45【问题描述】:根据我的Filestructure我遇到了错误liquibase.exception.SetupException:文件:/src/main/liquibase/changes/000-initial-schema.xml... 查看详情
liquibase-maven-plugin 与 testcontainers 的使用
】liquibase-maven-plugin与testcontainers的使用【英文标题】:Theusageofliquibase-maven-pluginwithtestcontainers【发布时间】:2021-12-0100:44:29【问题描述】:假设我有这个插件配置(使用hsqldb):<plugin><groupId>org.liquibase</groupId><artif... 查看详情
自定义spring-boot-autocofigure使用maven打包的时候报错了:failedtoexecutegoalorg.springframework.boot:spring-bo
报错信息如下:Failedtoexecutegoalorg.springframework.boot:spring-boot-maven-plugin:2.4.5:repackage(repackage)onprojectandy-hello-world-spring-boot-starter-autoconfiguration:Executionrepackageofgoalorg.spring 查看详情
无法通过我的 spring maven 项目集成和运行 liquibase
】无法通过我的springmaven项目集成和运行liquibase【英文标题】:Notabletointegrateandrunliquibasethroughmyspringmavenproject【发布时间】:2017-10-1418:59:39【问题描述】:我正在尝试通过基于弹簧的maven项目运行mvnliquibase:update。但我看到以下错... 查看详情
通过 maven liquibase 插件填充时,Hsqldb 没有数据
】通过mavenliquibase插件填充时,Hsqldb没有数据【英文标题】:Hsqldbhasnodatawhenpopulatedviamavenliquibaseplugin【发布时间】:2013-04-2403:25:32【问题描述】:我已创建架构并通过Mavenliquibase插件填充它:<plugin><groupId>org.liquibase</gro... 查看详情
如何在 Spring Boot 中配置 Maven Liquibase 插件?
】如何在SpringBoot中配置MavenLiquibase插件?【英文标题】:HowcanIconfigureMavenLiquibaseplugininSpringBoot?【发布时间】:2019-08-3023:35:24【问题描述】:我正在学习Liquibase和SpringBoot,所以我用SpringInitializr创建了一个简单的项目。在我添加的... 查看详情
Liquibase 看不到实体的变化
】Liquibase看不到实体的变化【英文标题】:Liquibasedonotseechangesinentities【发布时间】:2015-01-2309:16:05【问题描述】:我正在尝试使用liquibase配置简单的maven项目。我有很多关于liquibase-maven-plugin和liquibase-hibernate4版本的问题,它们不... 查看详情
Liquibase maven:spring-boot启动时找不到更改日志位置
】Liquibasemaven:spring-boot启动时找不到更改日志位置【英文标题】:Liquibasemaven:Cannotfindchangeloglocationwhenspring-bootstarts【发布时间】:2018-12-1416:38:01【问题描述】:我的liquibasemaven插件配置是:<plugin><groupId>org.liquibase</grou... 查看详情
Liquibase:diff 总是生成索引
】Liquibase:diff总是生成索引【英文标题】:Liquibase:diffalwaysgeneratesindexes【发布时间】:2018-02-1115:19:03【问题描述】:我使用spring-boot和liquibase-maven-plugin来根据我的类生成数据库更改,但是“mvncompileliquibase:diff”命令总是生成索... 查看详情
Liquibase 和 JPA 注释实体
】Liquibase和JPA注释实体【英文标题】:LiquibaseandJPAannotatedentities【发布时间】:2015-01-1014:17:03【问题描述】:我正在尝试将Liquibase与JPA注释一起使用,但我似乎无法正常工作。我的项目中有一个没有表和一个JPA实体的干净数据库... 查看详情
为啥 liquibase 无法解析 db.changelog 类路径?
】为啥liquibase无法解析db.changelog类路径?【英文标题】:Whyliquibaseunabletoresolvedthedb.changelogclasspath?为什么liquibase无法解析db.changelog类路径?【发布时间】:2018-03-3008:37:19【问题描述】:这是maven依赖jar项目之一的结构,其中一个... 查看详情
在生产环境中执行 liquibase 更新
】在生产环境中执行liquibase更新【英文标题】:Executeliquibaseupdateinproductionenvironment【发布时间】:2013-11-2901:03:00【问题描述】:我有一个JavaMaven项目。我正在使用liquibase来更新数据库。在本地,要更新我的数据库,我只是在命令... 查看详情
从 databasechangelog 读取 Liquibase 需要很长时间
】从databasechangelog读取Liquibase需要很长时间【英文标题】:Liquibasereadingfromdatabasechangelogtakesalongtime【发布时间】:2012-06-1312:14:00【问题描述】:有没有什么方法可以加快liquibase回滚和更新操作的maven任务?我现在在数据库中有大... 查看详情
自动回滚不适用于 Postgresql 上的 liquibase
】自动回滚不适用于Postgresql上的liquibase【英文标题】:AutorollbacknotworkingforliquibaseonPostgresql【发布时间】:2017-07-3105:08:36【问题描述】:我正在使用postgres数据库:Mavenpom.xml:<projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://w... 查看详情
无法初始化类 liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator
】无法初始化类liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator【英文标题】:Couldnotinitializeclassliquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator【发布时间】:2014-10-2202:11:12【问题描述】:当我尝试运行maven测试时遇到此问题。不确定... 查看详情
带有spring-boot的自定义sql中的Liquibase参数
】带有spring-boot的自定义sql中的Liquibase参数【英文标题】:Liquibaseparametersincustomsqlwithspring-boot【发布时间】:2019-04-1910:16:51【问题描述】:我在jdk11上有一个spring-boot应用程序,使用maven,具有以下liquibase依赖项:<dependency><... 查看详情
Liquibase 未能在 MySQL 上添加非空、唯一、当前时间戳
】Liquibase未能在MySQL上添加非空、唯一、当前时间戳【英文标题】:Liquibasefailedtoaddnotnull,unique,currenttimestamponMySQL【发布时间】:2017-08-2714:34:44【问题描述】:我正在自学如何使用Liquibase进行MySQL数据库版本控制和迁移。我正在使... 查看详情
通过maven创建springboot项目
1,idea选择创建一个maven项目2,pom.xml<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency> 查看详情