Search code examples
javaspring-bootliquibase

Reuse spring boot properties for liquibase configuration


I want to start use liquibase in my Spring Boot app. Now I already have db configuration, something like:

abc.datasource.jdbc-url=
abc.datasource.username=
abc.datasource.password=

For liquibase usage I also added the parameters to the same file with a same values:

spring.liquibase.url=
spring.liquibase.user=
spring.liquibase.password=

The question is: is it possible to configure it somehow to avoid duplication of the configuration values?


Solution

  • If you want to do it the same file declare shared properties and reference them below

    shared.datasource.jdbc-url=
    shared.datasource.username=
    shared.datasource.password=
    
    abc.datasource.jdbc-url=${shared.datasource.jdbc-url}
    abc.datasource.username=${shared.datasource.username}
    abc.datasource.password=${shared.datasource.password}
    
    spring.liquibase.url=${shared.datasource.jdbc-url}
    spring.liquibase.user=${shared.datasource.username}
    spring.liquibase.password=${shared.datasource.password}