Externalizing configuration in Spring Boot with multiple applications running in the same container

Viewed 2113

I'm building multiple Spring Boot applications which will be deployed on the same servlet container. But I'm having difficulties getting Spring Boot to work with externalized configuration files the way I want, and not like the framework wants.

Situation:

  • multiple Spring Boot applications will be deployed on a single servlet container (WAR file)
  • the location of configuration files will be set via JVM property spring.config.location
  • embedded deployment is not an option

Problem:

As the applications are deployed on the same JVM, the property spring.config.location has the same value for all applications. I want our applications to all use the same configuration file naming (application.properties), so specifying spring.config.name is not an option.

What I would like:

  • no need to set spring.config.name as the configuration name should be standardized accross all our applications (constant)
  • the externalized configuration properties should override values from application.properties packaged inside my deployed WAR
  • profile specific configurations (application-{profile}) should be possible
  • no hardcoded config locations in code
  • organizing configuration files in a per-application directory layout:

    ${spring.config.location}/app1/application.properties ${spring.config.location}/app2/application.properties ${spring.config.location}/app3/application.properties

Questions:

Is there some mechanism to influence or override loading or resolving of external configuration files?

Are there other approaches to get the desired result?

2 Answers
Related