本文介绍了liquibase 3.5.X找不到包含相对路径的includeAll的任何文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用liquibase 3.4.2,并希望更新到3.5.3,但我的所有尝试均失败了,因为liquibase找不到使用includeAll包含的任何文件.我已经测试了liquibase 3.5.0、3.5.1和3.5.3(由于此博客文章).

We are using liquibase 3.4.2 and want to update to 3.5.3 but all my attempts failed because liquibase doesn't find any file which are included by using includeAll. I have tested liquibase 3.5.0, 3.5.1 and 3.5.3 (I skipped 3.5.2 because of this blog post).

我的ChangeSet看起来像这样:

My ChangeSet looks like this:

<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.4.xsd">

    <includeAll path="relative/dir1" relativeToChangelogFile="true" errorIfMissingOrEmpty="true"/>
    <includeAll path="relative/dir2" relativeToChangelogFile="true" errorIfMissingOrEmpty="true"/>

</databaseChangeLog>

我的目录结构(在战争中包含的jar中)如下所示:

My directory structure (inside a jar which is included in a war) looks like this:

  • /some/dir/changeset.xml (上面的代码)
  • /some/dir/relative/dir1/another-changeset.xml
  • /some/dir/relative/dir2/another-changeset-1.xml
  • /some/dir/relative/dir2/another-changeset-2.xml
  • /some/dir/changeset.xml (the code above)
  • /some/dir/relative/dir1/another-changeset.xml
  • /some/dir/relative/dir2/another-changeset-1.xml
  • /some/dir/relative/dir2/another-changeset-2.xml

我已经通过liquibase进行调试,并停留在 ClassLoaderResourceAccessor.java:108 :

I have already debugged through liquibase and got stuck at ClassLoaderResourceAccessor.java:108:

if (entry.getName().startsWith(path)) {

在我的情况下,entry.getName()在第一个循环中返回some,然后返回some/dir,依此类推,直到some/dir/relative/dir1/another-changeset-1.xmlsome/dir/relative/dir2/another-changeset-1.xmlsome/dir/relative/dir2/another-changeset-2.xml.但是条件始终为假,因为path包含类似jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir1/jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir2/

In my case entry.getName() returns some in the first loop, then some/dir and so on till some/dir/relative/dir1/another-changeset-1.xml, some/dir/relative/dir2/another-changeset-1.xml and some/dir/relative/dir2/another-changeset-2.xml. But the condition is always false because path contains something like jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir1/ or jar:file:/C:/path/to/maven/project/war/target/example.war-1.0-SNAPSHOT/WEB-INF/lib/changesets-1.0-SNAPSHOT.jar!/relative/dir2/

从3.5.0开始,这真的是liquibase中的错误吗?如果我降级到liquibase 3.4.2,它会很好地工作.如果我使用include而不是includeAll,它也可以工作,但是在我的实际应用程序中,我拥有更多的变更集,并且我不想手动列出所有变更集.

Is this really a bug in liquibase since 3.5.0? It works perfectly if I downgrade to liquibase 3.4.2. It works also if I use include instead of includeAll but in my real application I have much more changesets and I don't want to list them all manually.

我找到了一些有关此的信息,但没有一个对我有帮助.为了完整起见:

I have found some information on this, but none of them helps me. For the sake of completeness:

  • Liquibase-JIRA: https://liquibase.jira.com/browse/CORE-2851, https://liquibase.jira.com/browse/CORE-2863, https://liquibase.jira.com/browse/CORE-2898, https://liquibase.jira.com/browse/CORE-2974
  • SO: Liquibase includeAll tag is ignored, includeAll path="" not working in 3.5.3, using java -jar method

推荐答案

尝试一下,

<includeAll path="file:/absolute/path/to/changeset/folder" relativeToChangelogFile="false" />

<includeAll path="file:/absolute/path/to/changeset/folder" relativeToChangelogFile="false" />

以file:/开头路径,并使用绝对路径.这不是很理想,但是我能够获得liquibase-maven-plugin 3.6.3来加载变更集.

Start the path with file:/ and use an absolute path. This is not ideal, but I was able to get liquibase-maven-plugin 3.6.3 to load the changeset.

这篇关于liquibase 3.5.X找不到包含相对路径的includeAll的任何文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 04:04