【发布时间】:2019-08-22 14:51:58
【问题描述】:
我在项目中有两个模块(integrationTest 和 main)运行集成测试。我希望在测试本身之前,我的应用程序将使用 liquibase 启动和滚动迁移,但是由于我通过集成测试模块运行应用程序,liquibase 正在寻找有关该模块的主文件,这会导致错误。因为主文件位于带有 miom 应用程序的模块中 (main)
我的项目的结构是这样的(为了紧凑省略了一些类):
PROJECT
└───dataMigration
│ build.gradle
│
└───src
├───main
│ ├───java
│ │ Application.java
│ │
│ └───resources
│ │ application.yml
│ │
│ └───db
│ └───changelog
│ db.changelog-master.xml
│ db.changelog-1.0.xml
│
└──integrationTest
├───java
│ IntegrationTest.java
│
└───resources
application-integration-tests.yml
如果我运行集成测试,则会收到以下错误
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)
如果我像往常一样运行我的应用程序(来自main 模块),那么一切正常。
如何让应用明白主文件在应用本身所在的模块中,而不是在集成测试模块中?
【问题讨论】:
-
如何以及在哪里指定 db.changelog-master.xml 的位置?
-
我在 application-integration-tests.yml 中指定了位置 db.changelog-master.xml 文件
-
change-log: classpath:../../main/resources/db/changelog/db.changelog-master.xml
标签: java spring spring-boot liquibase multi-module