== every source sets demo.greeting at once == $ DEMO_GREETING=from-environment-variable \ java -Ddemo.greeting=from-system-property \ -jar target/profiles-and-config-1.0.0.jar --spring.profiles.active=prod \ --demo.greeting=from-command-line-argument { "property": "demo.greeting", "effectiveValue": "from-command-line-argument", "activeProfiles": [ "prod", "prod-db", "prod-metrics" ], "holders": [ { "rank": 1, "source": "SimpleCommandLinePropertySource {name='commandLineArgs'}", "value": "from-command-line-argument", "origin": "\"demo.greeting\" from property source \"commandLineArgs\"" }, { "rank": 2, "source": "PropertiesPropertySource {name='systemProperties'}", "value": "from-system-property", "origin": "\"demo.greeting\" from property source \"systemProperties\"" }, { "rank": 3, "source": "OriginAwareSystemEnvironmentPropertySource {name='systemEnvironment'}", "value": "from-environment-variable", "origin": "System Environment Property \"DEMO_GREETING\"" }, { "rank": 4, "source": "OriginTrackedMapPropertySource {name='Config resource 'class path resource [application-prod.yaml]' via location 'optional:classpath:/''}", "value": "from-application-prod-yaml", "origin": "class path resource [application-prod.yaml] from profiles-and-config-1.0.0.jar - 4:13" }, { "rank": 5, "source": "OriginTrackedMapPropertySource {name='Config resource 'class path resource [application.yaml]' via location 'optional:classpath:/''}", "value": "from-application-yaml", "origin": "class path resource [application.yaml] from profiles-and-config-1.0.0.jar - 21:13" } ], "shadowedCount": 4 } == and with the environment variable removed, nothing else changed == ./scripts/demo-precedence.sh: line 41: 5735 Killed DEMO_GREETING=from-environment-variable setsid nohup java -Ddemo.greeting=from-system-property -jar "$JAR" --spring.profiles.active=prod --demo.greeting=from-command-line-argument > /tmp/profiles-precedence.log 2>&1 < /dev/null { "property": "demo.greeting", "effectiveValue": "from-system-property", "activeProfiles": [ "prod", "prod-db", "prod-metrics" ], "holders": [ { "rank": 1, "source": "PropertiesPropertySource {name='systemProperties'}", "value": "from-system-property", "origin": "\"demo.greeting\" from property source \"systemProperties\"" }, { "rank": 2, "source": "OriginTrackedMapPropertySource {name='Config resource 'class path resource [application-prod.yaml]' via location 'optional:classpath:/''}", "value": "from-application-prod-yaml", "origin": "class path resource [application-prod.yaml] from profiles-and-config-1.0.0.jar - 4:13" }, { "rank": 3, "source": "OriginTrackedMapPropertySource {name='Config resource 'class path resource [application.yaml]' via location 'optional:classpath:/''}", "value": "from-application-yaml", "origin": "class path resource [application.yaml] from profiles-and-config-1.0.0.jar - 21:13" } ], "shadowedCount": 2 } ./scripts/demo-precedence.sh: line 41: 5796 Killed setsid nohup java -Ddemo.greeting=from-system-property -jar "$JAR" --spring.profiles.active=prod > /tmp/profiles-precedence2.log 2>&1 < /dev/null