I have a spring boot application that has application.yml.
Contents of application.yml:
spring:
profiles:
active: default,private
integrations:
ecom:
api-url: http://localhost:8080/com
Contents of application-private.yml:
integrations:
ecom:
api-url: http://testenv:8080/com
As per my understanding, integrations:ecom:api-url are getting loaded from application-private.yml even though the default profile also has same property.
If two profiles are active, will the property be loaded and used in the order the profiles were specified?
My order:
-Dspring.profiles.active="default,private"
Thanks in Advance.
For your example, the following is the order of precedence in which Spring will get the value of the property (highest to lowest priority):
application-private.yml
provided outside your jar file (for example, via spring-cloud-config)application.yml
provided outside your jar file (application.yml is equivalent to application-default.yml)application-private.yml
provided inside your jar fileapplication.yml
provided inside your jar fileSo, if you have application-private.yml and application.yml inside the jar file, properties in the former override properties in the latter.
However, if application-private.yml is inside the jar but application.yml is outside, the latter will override the former.
See official documentation about external property precedence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With