2

I have below files under resources folder in a standard Spring Boot app . Spring.active.profile is set to dev In which order the properties files are read .?

1)application.yml 
2)bootstrap.yml
3)application_dev.yml
4)bootstrap_dev.yml
Pale Blue Dot
  • 511
  • 2
  • 13
  • 33

2 Answers2

2

As Spring doc mentions

Profile specific properties are loaded from the same locations as standard application.properties, with profiles specific files overriding the default ones

This would mean that first the application.yml is read and then the application_dev.yml is read and overrides values from the default application.yml if needed.

Same for bootstrap.yml and bootstrap-dev.yml

Also as you can see here

bootstrap.yml is loaded before application.yml.

So to answer your question the order should be

  1. bootstrap.yml
  2. bootstrap_dev.yml
  3. application.yml
  4. application_dev.yml
Panagiotis Bougioukos
  • 15,955
  • 2
  • 30
  • 47
0

bootstrap files are always the first: bootstrap.yml then bootstrap-{profile}.yml. then application.yml and application-{profile}.yml.

the property values are overridden by the next files so: a: 1 from application.yml will be overridden by a: 55 from application-{profile}.yml

red
  • 606
  • 10
  • 17