【问题标题】:liquibase command line: Cannot find the declaration of element 'changeSet'liquibase 命令行:找不到元素“changeSet”的声明
【发布时间】:2017-06-03 00:11:46
【问题描述】:

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

liquibase: cvc-elt.1: 找不到元素的声明 '更改集'。 liquibase:作为 SAXException 引发的错误:解析错误 ./1.xml 的第 3 行第 38 列:cvc-elt.1:找不到声明 元素'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 liquibase


【解决方案1】:

每个包含的文件都需要具有与标准变更日志相同的 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 的方式。

【讨论】:

  • 我没有包含任何文件,仍然出现同样的错误。
  • Vikash,您评论了一个非常古老的问题/答案。如果您遇到类似的问题,并且此答案对您没有帮助,那么您可能应该使用您自己的特定详细信息打开一个新问题。
【解决方案2】:

请参阅此处的帖子 - http://forum.liquibase.org/topic/declaration-not-found-databasechangelog。 在 xml 文件中将 xsd 版本从 3.0 更改为 2.0 对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    • 2012-07-02
    • 2012-11-28
    • 2012-09-14
    • 2016-09-09
    • 1970-01-01
    相关资源
    最近更新 更多