0

Spring boot provides solid configuration support and it has an ability to customize the external configuration loading sequence by controlling the spring profiles, explicitly by specifying loading sequence in system property spring.config.location

However I want to not override my application launchers everytime in dev/prod. I want to be able to have fixed loading sequence based on my requirement.

For example

config/
├── common.yml
├── env-common.yml
├── env-${dc}.yml
├── deployment-${deployment}-common.yml
├── deployment-${deployment}-${dc}.yml
├── foo-${foo}-common.yml
├── foo-${foo}-${dc}.yml
├── bar-${bar}-common.yml
├── bar-${bar}-${dc}.yml

I can achieve this loading sequence by controlling spring profiles, but is there a way I can hardcode this loading sequence inside my app ?

user3833308
  • 1,132
  • 3
  • 14
  • 39
  • Do you mean specifically, setting the "spring.config.location" in Java rather than having it as part of the java command line? – Compass Dec 04 '18 at 20:10
  • I was wondering if there is hookpoint to customize this. Setting the system property in Java might be too late. – user3833308 Dec 04 '18 at 20:58
  • I believe you can set the property in Java right before running the Spring Application. https://stackoverflow.com/questions/31267274/spring-boot-programmatically-setting-profiles You would have to manually substitute those properties though, as far as I know. – Compass Dec 04 '18 at 21:05
  • I do not want to repeat this in each entry point main. I would love to see if there is a way to customize it in spring way – user3833308 Dec 04 '18 at 21:25

0 Answers0