'Spring Boot yml file read order

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


Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Panagiotis Bougioukos
Solution 2