liquibase命令行:找不到元素'changeSet'的声明

Jef*_*eff 3 xml liquibase

我正在尝试组织我的更改集,以便每个文件都有一个changeset元素,如Liquibase最佳实践所暗示的那样,但是当我尝试在我的liquidbase xml文件上使用validate命令时,我收到以下错误.

liquibase:cvc-elt.1:找不到元素'changeSet'的声明.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>
Run Code Online (Sandbox Code Playgroud)

1.XML:

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

<changeSet  id="1" author="me">
    <createTable
        tableName="CLIENTS"
        ...
    </createTable>
</changeSet >
Run Code Online (Sandbox Code Playgroud)

Ste*_*nie 7

每个包含的文件都需要与标准更改日志具有相同的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 >
Run Code Online (Sandbox Code Playgroud)

您可能还需要在主更新日志中指定所包含的文件是相对于主更改日志的.

...
  <include file="1.xml" relativeToChangelogFile="true"/>
...
Run Code Online (Sandbox Code Playgroud)

是否需要这样做取决于你如何运行liquibase.