1

In spring-cloud projects, for some reason, need to put some properties into bootstrap.yml, so that to make the specific properties available earlier.

Then there are 2 config files: bootstrap.yml and application.yml.

Wondering is it ok to put everying into bootstrap.yml, and remove application.yml totally, to make it cleaner.

Since bootstramp.yml is just loaded earlier, it seems to be ok, right? Or, will this cause some issue in some case?

Eric
  • 22,183
  • 20
  • 145
  • 196
  • is application starting when you delete application.yml ? I dont think so it will. – karthick M Jul 12 '20 at 06:40
  • @KarthickM It can start, there is no problem. – Eric Jul 12 '20 at 06:58
  • 1
    If its starting, than you should be ok. we source configs-props form external config-src "https://www.vaultproject.io/docs/configuration" with no issues. As log as the config properties are loaded and you can see them in localhost/actuator/env you will be ok. Bootstrap should be fine as the source of config props. – z atef Jul 12 '20 at 07:12
  • Can you edit your question so I can upvote.. it's saying I down-voted, probably by mistake :( – z atef Jul 12 '20 at 07:14
  • Did I answer your question? – Muhammad Waqas Dilawar Jul 15 '20 at 10:54
  • @MuhammadWaqasDilawar Partly, I did the same test before, it works fine so far, but still that can't prove it's ok for any case I guess. – Eric Jul 15 '20 at 11:27
  • properties in application.yml gets overridden provided by server, so when using Spring Cloud I can't find any specific reason to have configurations in applicatio.yml. Plus updated answer with reference. – Muhammad Waqas Dilawar Jul 15 '20 at 11:40
  • @MuhammadWaqasDilawar Properties from `config server` is similar as `application.yml`, and it's a good practice I guess. – Eric Jul 15 '20 at 11:52

1 Answers1

1

Basically idea is to get configurations from ConfigServer using Spring Cloud Config. But sometimes we need some configurations e.g. spring.application.name upfront so, I'm using those configurations in bootstrap.yml. Which generally overrides what's in an application.yml [if present]). Reference

Plus, yes you can put all your configurations in bootstrap.yml and it works simply fine. I've tested with more than four microservices.

Muhammad Waqas Dilawar
  • 1,844
  • 1
  • 23
  • 34