简体   繁体   中英

Using Liquibase in multi module project

I have two modules ( editor and engine ) that work with a common database. For deployment of scripts I want to use liquibase . I do not want to duplicate the same scripts in two places, and I want to manage them in one place. To do this, I created a separate module ( database-structure ) that only contains my scripts and the parameter spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml . I have add this module ( database-structure ) as a dependency to my other modules. The final structure is as follows (classes are omitted for compactness):

D:\PROJECTS\MY-PROJECT
├───database-structure
│   │   pom.xml
│   │
│   └───src
│       ├───main
│       │   ├───java
│       │   └───resources
│       │       │   application.properties
│       │       │
│       │       └───db
│       │           └───changelog
│       │               │   db.changelog-master.xml
│       │               │
│       │               └───1.0
│       │                       db.changelog-1.0.xml
│       │                       metadata_create.sql
│       │                       metadata_insert_data.sql
│       │                       metadata_rollback.sql
│       │
│       └───test
│           └───java
├───editor
│   │   pom.xml
│   │
│   └───src
│       ├───main
│       │   ├───java
│       │   └───resources
│       │       │   application.properties
│       │       │
│       │       └───META-INF
│       │               spring.factories
│       │
│       └───test
│           ├───java
│           │   └───ru
│           │       └───test
│           │           └───editor
│           │               └───EditorControllerTest.java   
│           │
│           └───resources
│                   application.yml
│       
│
└───engine
    │   pom.xml
    │
    └───src
        ├───main
        │   ├───java
        │   └───resources
        │           application.yml
        │
        └───test
            ├───java
            └───resources

But, When I start tests in editor , for example ( EditorControllerTest.java ), I get error, that Liquibase not found:

Caused by: java.lang.IllegalStateException: Cannot find changelog location: class path resource [db/changelog/db.changelog-master.yaml] (please add changelog or check your Liquibase configuration)

But, I set spring.liquibase.change-log parameter in application.properties in database-structure module. Why it is ignored?

If I specify this option in the editor module, everything works. How to collect all of the logic work with the Liquibase in the same place in database-structure module?

But, I set spring.liquibase.change-log parameter in application.properties in database-structure module. Why it is ignored?

At runtime, as with any resources or classes, the first application.properties found on the classpath at the root ( / ) will be picked up the others will be ignored.

I've kept changelogs files in shared configuration: see Change working directory for gradle multi-module project

And then refer to them in every needed sub-modules: Applying Liquibase migrations for integration tests on a multi module gradle project

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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