liquibase命令行:找不到元素'changeSet'的声明 [英] liquibase command line: Cannot find the declaration of element 'changeSet'
问题描述
我正在尝试组织变更集,以使每个文件都有一个变更集元素,如 Liquibase最佳做法,但是当我尝试在我的Liquidbase xml文件上使用validate命令时,出现以下错误.
I'm trying to organize my changesets such that there is one changeset element per file, as implied by the Liquibase Best Practices, but I get the following error when i try to use the validate command on my liquidbase xml files.
liquibase:cvc-elt.1:找不到元素的声明 'changeSet'. liquibase:作为SAXException引发的错误:分析错误 ./1.xml的第3行第38列:cvc-elt.1:找不到以下内容的声明 元素"changeSet".
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:
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应该如下所示:
Each included file needs to have the same XML root node as a standard changelog - so your 1.xml should look like this:
<?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 >
您可能还需要在主变更日志中指定所包含的文件是相对于主变更日志的.
You may also need to specify in the master changelog that the included files are relative to the master changelog.
...
<include file="1.xml" relativeToChangelogFile="true"/>
...
是否需要执行此操作取决于liquibase的运行方式.
Whether you need to do that is dependent on how you run liquibase.
这篇关于liquibase命令行:找不到元素'changeSet'的声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!