【问题标题】:How do I use a Liquibase changelog which is in jar file如何使用 jar 文件中的 Liquibase 更改日志
【发布时间】:2015-08-01 22:11:55
【问题描述】:

我目前在我的application.properties 中有以下内容:

liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml

文件的实际路径是src/main/resources/db/changelog/db.changelog-master.xml

Liquibase 找到了更新日志,一切正常。

我已将变更日志以及项目的所有 JPA 实体和存储库移至单独的项目中,以便与其他项目共享。

第二个项目是第一个项目的 Maven 依赖项。我需要在第一个项目的application.properties 中使用什么路径来访问第二个项目中的 liquibase 变更日志?

更新

我有:

projectA.jar -> pom.xml

<dependency>
    <groupId>com.foo</groupId>
    <artifactId>projectB</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

projectA.jar -> application.properties

liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml

projectB.jar -> src/main/resources/db/changelog/db.changelog-master.xml

但我得到了:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.xml] (please add changelog or check your Liquibase configuration)

【问题讨论】:

  • 同一个。如果 jar 在类路径中,并且您没有更改 changelog 文件的包,那么一切都应该正常。
  • 这似乎不起作用。我不明白它是如何知道路径在第二个 jar 文件中的。
  • 我收到以下错误Caused by: java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.xml] (please add changelog or check your Liquibase configuration)
  • @JBNizet 当我在 IntelliJ 中运行测试时它工作正常,但当我在 IntelliJ 之外运行测试时失败。假设存在类路径问题?

标签: java spring maven spring-boot liquibase


【解决方案1】:

我是个白痴。我的本地 ~/.m2 存储库有一个旧版本的 jar,没有 Liquibase 更改日志。 mvn clean install 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-12
    • 2011-11-12
    • 2015-01-27
    • 2018-03-05
    • 2021-11-30
    • 1970-01-01
    • 2020-02-16
    • 1970-01-01
    相关资源
    最近更新 更多