Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 824
All_Safe Avatar asked Nov 06 '22 16:11

All_Safe


1 Answers

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.

like image 193
Puce Avatar answered Nov 14 '22 22:11

Puce