0

I have a multi-module maven based project which has a number of Spring Boot applications, a couple of which (lets call them A and B) connect to a database (I have a separate module with the database related code on which both applications depend.) I am also using Flyway to maintain the database versioning and maintain the database structure.

What is the best approach to maintain the database properties? At the moment I have 3 places where I am repeating the same thing. I have the application.yml of module A and application.yml of module B, since both are separate Spring Boot applications. Then I have the Flyway plugin configuration again which needs the properties in the pom.xml to be able to perform its tasks, like clean, repair and migrate.

What is the proper approach to centralise and externalise this information, like the database URL, username and password? I am also facing the issue that each time I pull the new code onto the test system I have to update the same data again because it gets overwritten, and the database configuration on the test system is different from my local development environment.

What is the best strategy to manage this?

jbx
  • 21,365
  • 18
  • 90
  • 144

2 Answers2

0
  1. Externalize your configuration into a configuration module. This, of course, depends on how flexible Flyway / Spring Boot are from using classpath based properties.

  2. Look at something like archaius and make your configuration truly externalized, centralized and dynamic by having it backed by, say, an external datastore. More work involved here but gives you additional benefits, like being able to change config in one place and have them dynamically picked up in running applications everywhere.

It's not an easy problem to solve and definitely involves some work to make your tools cooperate by hooking into their lifecycle.

markdsievers
  • 7,151
  • 11
  • 51
  • 83
  • Yes there doesn't seem to be a straightforward answer, and I am really looking into finding the most standard approach commonly used. – jbx Nov 12 '16 at 10:18
0

For your flyway you could use the maven-properties-plugin. In that way you can externalize the credential to a properties file. An example is described here.

For the spring-boot application I will recommend the spring cloud config . With the spring cloud config you can externalize your config to a git repository which can be discovered over an Eureka Service, e.g. like here. I will consider to restructure the modules to independent microservices. A good infrastructure for a microservice based architecture provides the JHipster project.

Community
  • 1
  • 1
duderoot
  • 977
  • 1
  • 8
  • 23