简体   繁体   English

Liquibase Maven 无法读取 changeLogFile

[英]Liquibase Maven can't read changeLogFile

According to my File structure I got an error根据我的文件结构,我得到了一个错误

liquibase.exception.SetupException: file:/src/main/liquibase/changes/000-initial-schema.xml does not exist liquibase.exception.SetupException:文件:/src/main/liquibase/changes/000-initial-schema.xml 不存在

My pom.xml plugin is configured like this:我的 pom.xml 插件配置如下:

<build>
    <plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.5.3</version>
            <configuration>
                <propertyFile>src/main/liquibase/liquibase.properties</propertyFile>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>update</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

My liquibase.properties files are:我的 liquibase.properties 文件是:

driver=com.mysql.jdbc.Driver驱动程序=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/versioned url=jdbc:mysql://localhost:3306/versioned
username=用户名=
password=密码=
changeLogFile=src/main/liquibase/master.xml changeLogFile=src/main/liquibase/master.xml

My master.xml is我的 master.xml 是

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<includeAll path="src/main/liquibase/changes" />
</databaseChangeLog>

Why Liquibase can't find that file ?为什么 Liquibase 找不到那个文件? Even if i change that file name to: 000-initial-schemaTEST.xml the error is:即使我将该文件名更改为:000-initial-schemaTEST.xml 错误是:

liquibase.exception.SetupException: file:/src/main/liquibase/changes/000-initial-schemaTEST.xml does not exist liquibase.exception.SetupException:文件:/src/main/liquibase/changes/000-initial-schemaTEST.xml 不存在

I'm putting also that file (it was generated from database by generateChangeLog goal)我也在放那个文件(它是通过 generateChangeLog 目标从数据库生成的)

<?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: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/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<changeSet author="arek (generated)" id="1489753245544-1">
    <createTable tableName="user">
        <column autoIncrement="true" name="id" type="INT">
            <constraints primaryKey="true"/>
        </column>
        <column name="name" type="VARCHAR(255)">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet>
<changeSet author="arek (generated)" id="1489753245544-2">
    <addUniqueConstraint columnNames="id" constraintName="id_UNIQUE" tableName="user"/>
</changeSet>

To comparation when master.xml file is:比较master.xml文件为:

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

<include file="src/main/liquibase/changes/001-add-user-address.xml" />
<!--<includeAll path="src/main/liquibase/changes" />-->
</databaseChangeLog>

It works有用

The reason of that was maven Liquibase version.原因是 maven Liquibase 版本。

That error happens only in versions:该错误仅发生在版本中:

  • 3.5.3 3.5.3
  • 3.5.2 3.5.2

In 3.5.1 and below it works.在 3.5.1 及以下版本中它有效。

Maybe someone knows why it not works in 3.5.2 and 3.5.3 and how it should be configured in these versions ?也许有人知道为什么它在 3.5.2 和 3.5.3 中不起作用以及在这些版本中应该如何配置?

解决方案是更新master.xml

<includeAll path="changes" relativeToChangelogFile="false" />

liquibase find the files to include but do not load them correctly. liquibase 找到要包含的文件,但没有正确加载它们。

In this example, liquibase find the file include.xml when listing the content of your folder but don't manage to load it.在这个例子中,liquibase 在列出文件夹的内容时找到了文件 include.xml 但没有设法加载它。

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project testLiquibase: Error setting up or running Liquibase: liquibase.exception.SetupException: file:/src/main/resources/include/include.xml does not exist -> [Help 1]

This issue is track: https://liquibase.jira.com/browse/CORE-2980这个问题是跟踪: https : //liquibase.jira.com/browse/CORE-2980

在我的情况下,解决方案是为每个“包含”标记添加到 db-changelog-master.xml,语句:relativeToChangelogFile="true" 如下所示:

<include file="e6ebb/ddl/61-someChanges.xml" relativeToChangelogFile="true"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM