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
CodePudding user response:
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
CodePudding user response:
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
- bootstrap.yml
- bootstrap_dev.yml
- application.yml
- application_dev.yml