xml - liquibase 命令行 : Cannot find the declaration of element 'changeSet'

标签 xml liquibase

我正在尝试组织我的变更集,以便每个文件有一个变更集元素,正如 Liquibase Best Practices 所暗示的那样,但是当我尝试对我的 liquidbase xml 文件使用验证命令时出现以下错误。

liquibase: cvc-elt.1: Cannot find the declaration of element 'changeSet'. liquibase: Error thrown as a SAXException: Error parsing line 3 column 38 of ./1.xml: cvc-elt.1: Cannot find the declaration of element 'changeSet'.

我做错了什么?

master.xml:

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

    <include file="./1.xml"/>
    <include file="./2.xml"/>
</databaseChangeLog>

1.xml:

<?xml version="1.0" encoding="utf-8" ?>

<changeSet  id="1" author="me">
    <createTable
        tableName="CLIENTS"
        ...
    </createTable>
</changeSet >

最佳答案

每个包含的文件都需要具有与标准变更日志相同的 XML 根节点 - 因此您的 1.xml 应如下所示:

<?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"
    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
    http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
  <changeSet  id="1" author="me">
      <createTable
          tableName="CLIENTS"
          ...
      </createTable>
  </changeSet >

您可能还需要在主变更日志中指定包含的文件是相对于主变更日志的。

...
  <include file="1.xml" relativeToChangelogFile="true"/>
...

是否需要这样做取决于您运行 liquibase 的方式。

关于xml - liquibase 命令行 : Cannot find the declaration of element 'changeSet' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23540464/

相关文章:

delimiter - db 中 "endDelimiter:@"的用途是什么(在我的例子中是 liquibase)

postgresql - Liquibase generateChangeLog 不会使用 postgres 检索所有模式

JavaScript——这个单选按钮被选中了吗?

python - 生成/写入 XML 文件的标准方式

java - 忽略使用 xmlunit 在一个 xml 文件中注释掉的那些元素

liquibase - 为什么在更新时未指定时所有上下文都会执行?

oracle12c - liquibase 3.5.x 在执行变更集时是否有默认超时?

xml - 如果 DTD 链接无处可去,会发生什么情况?

c# - 如何使用 XElement.ToString() 包含声明

gradle - 在Gradle Liquibase中使用属性