gpt4 book ai didi

mysql - 在idea中调试启动Spring boot应用程序时,Liquibase再次运行变更集

转载 作者:行者123 更新时间:2023-11-29 10:15:58 25 4
gpt4 key购买 nike

当我在默认运行模式下启动 Spring Boot 应用程序时,它会正常执行 liquibase 语句。

停止并再次运行会正常跳过变更集,因为它已经执行了。

以 Debug模式启动,但尝试再次执行变更集,即使它已经运行。

我扭转了局面,首先在调试中执行了更改,这巧妙地在数据库更改日志中创建了条目当在非 Debug模式下第二次运行它时,会发生同样的情况

我的更改是 native sql格式,数据库是带有mysql连接器的mariadb

我比较了两个数据库更改日志(先运行与先调试)条目的 md5 总和,它们是相同的。

liquibase版本是3.5.4我也测试了3.5.5,结果相同

mysql Ver 15.1 Distrib 10.0.34-MariaDB,适用于 debian-linux-gnu (x86_64),使用 readline 5.2

这也是 liquibase 失败的日志记录部分

2018-05-01 13:54:00.610 DEBUG 27486 --- [           main] liquibase                                : Connected to xxx@localhost@jdbc:mysql://localhost:3306/project1_db?nullNamePatternMatchesAll=true
2018-05-01 13:54:00.610 DEBUG 27486 --- [ main] liquibase : Setting auto commit to false from true
2018-05-01 13:54:00.642 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOGLOCK
2018-05-01 13:54:00.647 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOGLOCK
2018-05-01 13:54:00.648 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT LOCKED FROM project1_db.DATABASECHANGELOGLOCK WHERE ID=1
2018-05-01 13:54:00.649 DEBUG 27486 --- [ main] liquibase : Lock Database
2018-05-01 13:54:00.655 DEBUG 27486 --- [ main] liquibase : Executing UPDATE database command: UPDATE project1_db.DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)', LOCKGRANTED = '2018-05-01 13:54:00.650' WHERE ID = 1 AND LOCKED = 0
2018-05-01 13:54:00.657 INFO 27486 --- [ main] liquibase : Successfully acquired change log lock
2018-05-01 13:54:00.672 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/db.changelog-master.yaml as classpath:/db/changelog/db.changelog-master.yaml
2018-05-01 13:54:00.687 DEBUG 27486 --- [ main] liquibase : includeAll for db/changelog/changes/
2018-05-01 13:54:00.687 DEBUG 27486 --- [ main] liquibase : Using file opener for includeAll: liquibase.integration.spring.SpringLiquibase$SpringResourceOpener(jdk.internal.loader.ClassLoaders$AppClassLoader)
2018-05-01 13:54:00.690 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/changes/db.change.sql as db/changelog/changes/db.change.sql
2018-05-01 13:54:00.690 DEBUG 27486 --- [ main] liquibase : Opening file:/home/xxx/project1-connector/project1-backend/target/classes/db/changelog/changes/db.change.sql as db/changelog/changes/db.change.sql
2018-05-01 13:54:00.694 DEBUG 27486 --- [ main] liquibase : Computed checksum for 1525175640693 as 422ae5f56810de3fc5eeb17bb4af5afe
2018-05-01 13:54:00.710 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT MD5SUM FROM project1_db.DATABASECHANGELOG WHERE MD5SUM IS NOT NULL LIMIT 1
2018-05-01 13:54:00.711 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: select count(*) from project1_db.DATABASECHANGELOG
2018-05-01 13:54:00.712 INFO 27486 --- [ main] liquibase : Reading from project1_db.DATABASECHANGELOG
2018-05-01 13:54:00.712 DEBUG 27486 --- [ main] liquibase : Executing QUERY database command: SELECT * FROM project1_db.DATABASECHANGELOG ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
2018-05-01 13:54:00.716 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Computed checksum for inputStream as 0c73ccd0174246a5a7fab00d26cc30d2
2018-05-01 13:54:00.720 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Computed checksum for 7:0c73ccd0174246a5a7fab00d26cc30d2: as 22c8e24ae058e8e523819972d470a98a
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Running Changeset:db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Changeset db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.721 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Reading ChangeSet: db/changelog/changes/db.change.sql::basicdata::xxx
2018-05-01 13:54:00.727 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Executing Statement: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')
2018-05-01 13:54:00.728 DEBUG 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Executing EXECUTE database command: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')
2018-05-01 13:54:00.733 ERROR 27486 --- [ main] liquibase : classpath:/db/changelog/db.changelog-master.yaml: db/changelog/changes/db.change.sql::basicdata::xxx: Change Set db/changelog/changes/db.change.sql::basicdata::xxx failed. Error: Duplicate entry '1' for key 'PRIMARY' [Failed SQL: insert into company (id, name, created_at, created_by)
values (1, 'mycompany', now(), 'xxx')]

最佳答案

我猜这可能是逻辑文件路径的问题。也许您的类路径在调试和正常运行中略有不同。尝试在您的 sql 文件中指定它。 look here获取信息。

关于mysql - 在idea中调试启动Spring boot应用程序时,Liquibase再次运行变更集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50116146/

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