简体   繁体   English

liquibase 不使用 java -jar SpringBoot 运行

[英]liquibase does not run with java -jar SpringBoot

I am trying to integrate liquibase with an existing project.我正在尝试将 liquibase 与现有项目集成。 When testing liquibase locally I have been using IntelliJ which I think is equivalent to mvn spring-boot:run in this case when the app starts liquibase runs the update and checks that all the changelogs have been completed.在本地测试 liquibase 时,我一直在使用 IntelliJ,我认为它相当于mvn spring-boot:run在这种情况下,当应用程序启动时 liquibase 运行更新并检查所有更改日志是否已完成。

When I compile into a jar ( mvn clean install ) and run java -jar app.jar liquibase simply prints out:当我编译成一个 jar ( mvn clean install ) 并运行java -jar app.jar liquibase 简单地打印出来:

 15:17:08.769 [main] INFO  liquibase.lockservice - Successfully acquired change log lock
 15:17:09.013 [main] INFO  liquibase.changelog - Creating database history table with name: "app".databasechangelog
 15:17:09.028 [main] INFO  liquibase.changelog - Reading from "app".databasechangelog
 15:17:09.078 [main] INFO  liquibase.lockservice - Successfully released change log lock

and does not apply any of the changesets so obviously it immediately crashes because none of the tables have been set up (if I'm running it on a new database).并且不应用任何变更集,因此很明显它立即崩溃,因为没有设置任何表(如果我在新数据库上运行它)。 My understanding is that in a spring boot app with default configuration liquibase should run on start up.我的理解是,在具有默认配置 liquibase 的 Spring Boot 应用程序中,应该在启动时运行。 I thought that this could be a dependency issue but then why would liquibase be running at all?我认为这可能是一个依赖性问题,但为什么 liquibase 会运行呢?

Can anyone give some pointers on what I can check to support this?任何人都可以就我可以检查的内容提供一些指示以支持这一点吗? Does liquibase just not run on startup unless it's a specific "spring boot run"?除非是特定的“spring boot run”,否则 liquibase 是否不会在启动时运行?

Thanks谢谢

Changelogs added by request:按要求添加的变更日志:

db.changelog-root.xml db.changelog-root.xml

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<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-3.5.xsd"
                   logicalFilePath="root"
>
    <!-- NOTE: path is relative from src/main/resources -->
    <includeAll path="./db/changelog"/>
</databaseChangeLog>

changelog-2.5.0.xml变更日志-2.5.0.xml

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog logicalFilePath="2.5.0" xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" 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/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
    <preConditions onFail="WARN" onFailMessage="Non postgres databases are not supported for SI, good luck!">
        <dbms type="postgresql"/>
    </preConditions>
    <changeSet author="kidd (manual)" id="tag-version-2.1.0">
        <tagDatabase tag="2.5.0"/>
    </changeSet>

    <!-- mobile_uid_seq -->
    <changeSet author="kidd (modified)" id="1635825727316-1">
        <preConditions onFail="MARK_RAN">
            <not>
                <sequenceExists sequenceName="mobile_uid_seq"/>
            </not>
        </preConditions>
        <createSequence cacheSize="1" cycle="false" dataType="bigint" incrementBy="1" maxValue="9223372036854775807" minValue="-1" sequenceName="mobile_uid_seq" startValue="-1"/>
    </changeSet>

<!-- ... a lot more changesets --> 
</databaseChangeLog>

The problem was solved by changing问题已通过更改解决

<includeAll path="./db/changelog"/> to <includeAll path="/db/changelog"/> . <includeAll path="./db/changelog"/><includeAll path="/db/changelog"/> Though if anyone could explain why this would be different between running the compiled jar ( java -jar app.jar ) and mvn:spring-boot run that would be interesting to me.尽管如果有人能解释为什么运行编译的 jar ( java -jar app.jar ) 和mvn:spring-boot run之间会有所不同,那我会很感兴趣。 I understand that the filepaths change when compiled however, even looking in the target folder it should still be the same relevant path right (in this case db is the root folder following the normal liquibase layout).我知道编译时文件路径会发生变化,即使在target文件夹中查看它仍然应该是相同的相关路径(在这种情况下, db是遵循正常 liquibase 布局的根文件夹)。 So still slightly confused as to why ./ should not work in this case.所以仍然有点困惑为什么./在这种情况下不应该工作。

Regardless, if anyone faces this problem again do not use relative paths even when within the resources folder!无论如何,如果有人再次遇到这个问题,即使在资源文件夹中也不要使用相对路径!

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

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