gpt4 book ai didi

xml-parsing - Liquibase "Cannot find the declaration of element ' databaseChangeLog'”在xml changeLog文件中

转载 作者:行者123 更新时间:2023-12-05 08:49:35 24 4
gpt4 key购买 nike

根据 Liquibase 官方网站上的 This guide,我创建了自己的 changelog-master.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="https://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.liquibase.org/xml/ns/dbchangelog https://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">
<includeAll path="/home/username/liquibase/examples/sqlite-test" filter="sql"/>
</databaseChangeLog>

然后我在同一文件夹中创建了 liquibase.properties 文件:

# Enter the path for your changelog file.
changeLogFile=changelog-master.xml

#### Enter the Target database 'url' information ####
url=jdbc:sqlite://home/username/liquibase/examples/sqlite-test/testdb

这是正确的,因为如果我运行普通的 .sql 变更日志,它会正确运行并更新我的数据库。

然后我在 sql 中创建了一个更改日志文件,它必须在启动 liquibase update 时自动执行,它是 000020-changelog.sql

--liquibase formatted sql

--changeset daniel:3
create table phonebook(name TEXT, surname TEXT, type TEXT, phone_number TEXT);

但是当我启动 liquibase update 时,我从 XML 解析器中得到一个错误:

Unexpected error running Liquibase: cvc-elt.1.a: Cannot find the declaration of element 'databaseChangeLog'.

我不明白问题出在哪里。我已经多次检查 changelog-master.xml 文件是否正确并且看起来是正确的。据我所知,cvc-elt.1.a 是一个 XML 解析错误,例如 databaseChangeLog,它未在 xml 架构中声明。

我这样做是为了将来我可以创建任意数量的变更日志,并让它们一个接一个地自动执行。

我一直在寻找这个问题的一些解决方案,但我找不到任何东西。我找到了一个指向官方论坛的链接,但它现在是一个无效链接。

额外信息:

  • Liquibase 版本 4.0.0
  • 已安装 JRE:openjdk 11.0.8 2020-07-14
  • 操作系统:Debian 10
  • SQLite 版本 3.27.2

2020 年 8 月 9 日编辑:

正如评论中所要求的,这是项目的结构:

root@dev-machine:/home/username/liquibase/examples/sqlite-test# ls -la
total 68
drwxr-xr-x 2 root root 4096 Sep 4 17:28 .
drwxr-xr-x 5 username username 4096 Sep 4 17:02 ..
-rw-r--r-- 1 root root 139 Sep 4 13:35 000020-changelog.sql
-rw-r--r-- 1 root root 118 Sep 4 13:36 000030-changelog.sql
-rw-r--r-- 1 root root 201 Sep 4 17:05 000040-changelog.sql
-rw-r--r-- 1 root root 240 Sep 4 17:28 000050-changelog.sql
-rw-r--r-- 1 root root 456 Sep 4 14:22 changelog-master.xml
-rw-r--r-- 1 root root 2637 Sep 4 16:36 liquibase.properties
-rw-r--r-- 1 root root 32768 Sep 4 17:28 testdb

testdb 是我用来测试 liquibase 的 sqlite 数据库。 .sql 文件是必须运行以更新数据库的连续更改日志

最佳答案

导致我遇到问题的原因是,在我的 changelog-master.xml 中,我有一个过时的 XSD 版本,这导致某些东西破坏了 XML 解析器。为了修复它,我用以下内容更改了它:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro
http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd
">
<includeAll path="schema/"/>
</databaseChangeLog>

并将我所有的 *.sql 文件移动到 schema/ 文件夹中。除此之外,我使用 *.databasetype.sql 命名方案重命名了我所有的 .sql 文件,在我的例子中是 000020-changelog.sqlite.sql。必须这样做,否则使用 --liquibase 格式的 sql 的文件将不会被执行。

关于xml-parsing - Liquibase "Cannot find the declaration of element ' databaseChangeLog'”在xml changeLog文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63741980/

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