【问题标题】:Liquibase Maven can't read changeLogFileLiquibase Maven 无法读取 changeLogFile
【发布时间】:2017-08-10 01:11:45
【问题描述】:

根据我的 File structure 我遇到了错误

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

我的 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>

我的 liquibase.properties 文件是:

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

我的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>

为什么 Liquibase 找不到那个文件?即使我将该文件名更改为: 000-initial-schemaTEST.xml 错误是:

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

我也放了那个文件(它是由 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>

对比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>

有效

【问题讨论】:

    标签: java xml maven plugins liquibase


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      解决办法是更新ma​​ster.xml

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

      【讨论】:

        【解决方案3】:

        liquibase 找到要包含的文件,但未正确加载它们。

        在本例中,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]
        

        此问题跟踪:https://liquibase.jira.com/browse/CORE-2980

        【讨论】:

          【解决方案4】:

          原因是 maven Liquibase 版本。

          该错误仅在版本中发生:

          • 3.5.3
          • 3.5.2

          在 3.5.1 及以下版本中有效。

          也许有人知道为什么它在 3.5.2 和 3.5.3 中不起作用,以及在这些版本中应该如何配置?

          【讨论】:

          • 还有版本 3.6.2。
          • 和版本 3.6.3
          猜你喜欢
          • 2016-07-05
          • 2020-06-21
          • 2019-12-16
          • 2020-04-28
          • 2020-09-25
          • 1970-01-01
          • 2021-08-06
          • 2013-09-25
          • 2013-09-25
          相关资源
          最近更新 更多