== does application-prod.yaml win? == demo.datasource-url is set in application.yaml and again in application-prod.yaml. --- 1. prod profile active, no environment variable --- $ java -jar target/profiles-and-config-1.0.0.jar --spring.profiles.active=prod active profiles : prod, prod-db, prod-metrics effective value : jdbc:postgresql://prod-db:5432/orders 1. jdbc:postgresql://prod-db:5432/orders <- 'file application-prod.yaml' via location 'optional:classpath:/''} 2. jdbc:h2:mem:default <- 'file application.yaml' via location 'optional:classpath:/''} holders that lost: 1 --- 2. identical, plus one leftover environment variable --- $ DEMO_DATASOURCE_URL=jdbc:postgresql://leftover:5432/orders \ java -jar target/profiles-and-config-1.0.0.jar --spring.profiles.active=prod active profiles : prod, prod-db, prod-metrics effective value : jdbc:postgresql://leftover:5432/orders 1. jdbc:postgresql://leftover:5432/orders <- OriginAwareSystemEnvironmentPropertySource {name='systemEnvironment'} 2. jdbc:postgresql://prod-db:5432/orders <- 'file application-prod.yaml' via location 'optional:classpath:/''} 3. jdbc:h2:mem:default <- 'file application.yaml' via location 'optional:classpath:/''} holders that lost: 2 The profile-specific file is still loaded and still holds its value -- it is listed, and it lost. Config data is item 3 in the documented precedence list; OS environment variables are item 5, and later items win. == the full property-source stack, in order == $ curl -s localhost:8080/sources 1. MapPropertySource server.ports 2. ConfigurationPropertySourcesPropertySource configurationProperties 3. SimpleCommandLinePropertySource commandLineArgs 4. StubPropertySource servletConfigInitParams 5. ServletContextPropertySource servletContextInitParams 6. PropertiesPropertySource systemProperties 7. OriginAwareSystemEnvironmentPropertySource systemEnvironment 8. RandomValuePropertySource random 9. OriginTrackedMapPropertySource Config resource 'class path resource [application-prod-metrics.yaml]' via location 'optional:classpath:/' 10. OriginTrackedMapPropertySource Config resource 'class path resource [application-prod-db.yaml]' via location 'optional:classpath:/' 11. OriginTrackedMapPropertySource Config resource 'class path resource [application-prod.yaml]' via location 'optional:classpath:/' 12. OriginTrackedMapPropertySource Config resource 'class path resource [application.yaml]' via location 'optional:classpath:/' 13. ApplicationInfoPropertySource applicationInfo