-1

I have a Spring Boot application which works as microservice.

This application has several config files in resources

  1. Common config which works for all profiles

  2. One config file specific for each profile (dev, test, prod)

All works fine with config files in application resources.

Now I want to externalize profile specific config file to external file.

I used to use this kind of Dockerfile

(with --spring.config.location option)

FROM adoptopenjdk/openjdk11:alpine-jre
ADD /revise.jar /revise.jar
ADD /application.yml /application.yml
ENTRYPOINT ["java", "-jar", "/revise.jar", "--spring.config.location=file:/application.yml"]

or (with --spring.config.import option)

FROM adoptopenjdk/openjdk11:alpine-jre
ADD /revise.jar /revise.jar
ADD /application.yml /application.yml
ENTRYPOINT ["java", "-jar", "/revise.jar", "--spring.config.import=file:/application.yml"]

But external config file doesn't merge with common config file. In other words if in externalized config file (application.yml) I use full config application starts and works, but if I use content of profile specific file it doesn't work.

Could you suggest me how to use external config file which could merge with common config file of application?

Alex Zhulin
  • 1,239
  • 2
  • 22
  • 42
  • Does this answer your question? [Spring Boot and multiple external configuration files](https://stackoverflow.com/questions/25855795/spring-boot-and-multiple-external-configuration-files) – 1615903 Nov 02 '21 at 04:35
  • "spring.config.location now overrides the default instead of adding to it. You need to use spring.config.additional-location to keep the defaults." – 1615903 Nov 02 '21 at 04:35

1 Answers1

0

I hope you're naming the profile specific files as application-qa.yml etc. Once you do that you can point the config location to that file and also mention the spring active profile in your docker command java -jar -Dspring.profiles.active=qa

Ananya Antony
  • 338
  • 3
  • 15
  • Thank you, but how it will help me to achieve my goal: merge external config file with internal config file of the app? – Alex Zhulin Nov 02 '21 at 04:07