[英]Liquibase Maven can't read changeLogFile
根據我的文件結構,我得到了一個錯誤
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 文件是:
驅動程序=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>
有用
原因是 maven Liquibase 版本。
該錯誤僅發生在版本中:
在 3.5.1 及以下版本中它有效。
也許有人知道為什么它在 3.5.2 和 3.5.3 中不起作用以及在這些版本中應該如何配置?
解決方案是更新master.xml :
<includeAll path="changes" relativeToChangelogFile="false" />
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
在我的情況下,解決方案是為每個“包含”標記添加到 db-changelog-master.xml,語句:relativeToChangelogFile="true" 如下所示:
<include file="e6ebb/ddl/61-someChanges.xml" relativeToChangelogFile="true"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.