java - Liquibase Maven 无法读取 changeLogFile

标签 java xml maven plugins liquibase

据我所知 File structure 我遇到了一个错误

liquibase.exception.SetupException: file:/src/main/liquibase/changes/000-initial-schema.xml does not exist

我的 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
username=
password=
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: file:/src/main/liquibase/changes/000-initial-schemaTEST.xml does not exist

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

有效

最佳答案

解决方法是更新ma​​ster.xml:

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

关于java - Liquibase Maven 无法读取 changeLogFile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42875117/

相关文章:

java - 使用组合(java)时如何实现关闭开关?

java - Commons XMLConfiguration 和模式验证?

xml - 从 XSLT 中抛出异常

java - CheckStyle SuppressionFilter 模块文件路径以实现 Eclipse 和 Maven 兼容性

java - 以编程方式获取 Maven Artifact

java - 如何通过gradle更改Java代码行?

java - 使用 Ribbon 自动重试(无 zuul): not working + wrong documentation?

java - 为什么我需要将私有(private)类声明为静态以避免 "Generic Array Creation"错误?

c++ - 无法将 splitterChannel 与 poco 的高级 xml 配置一起使用

java - 使用 JPA 和 Hibernate : Persistence. xml 进行 JUnit 测试