Configurationmedium3-5 years

How does Spring Boot decide which value wins when the same property is set in application.yml, a profile-specific file, an environment variable and a command-line argument?

Spring Boot layers property sources and resolves each property from the highest-priority source that defines it. Roughly, from highest to lowest: command-line arguments, JVM system properties, OS environment variables, profile-specific application-{profile}.yml, then the base application.yml, then defaults in code. A more specific source always wins over a less specific one, and spring.profiles.active decides which profile-specific file(s) even get consulted.

The lesson behind it →
More on Configuration