Is there any way to generate effective application yml or properties being used for running spring boot process especially from java perspective
lets say we have bunch of profile based yamls and active profile is passed at startup can we have a way to identify effective yaml made post all overrides in yaml tree?
Comment From: snicoll
There isn't one effective "yaml" really as we have sources from OS env variables and system properties where most of them are certainly unrelated to the scope of the app. You can query the environment endpoint of the actuator to know which value is effectively used for a key (/actuator/env/my.key
) and you also query the configprops endpoint to know the values that have been bound to @ConfigurationProperties
. Based on those services, it would be doable to build a small service that queries the keys you care about.
Going forward, please ask questions on StackOverflow, as mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.
Comment From: onacit
Sorry for the comment on a closed (and labeled with for:stackoverflow
) issue, but I was about to create an issue requesting a feature for a task in a SpringBootPlugin
.
Not all developers (and their bosses) want the actuator nor a bunch of specific logic in there main
method.
@snicoll If I may, How about a task prints effective application properties applied for given invocation?
Say,
$ ./gradlew -Dspring.profiles.active=local bootApplicationProperties
...
... Prints processed and effectively applied application.properties
...
$
Thanks.
Comment From: philwebb
@onacit Application properties come from a variety of sources and can change depending on the application. The actuator is able to display information because it's part of the running application. A gradle task wouldn't be able to do the same thing. A relatively small change, for example running with --spring.profiles.active=prod
might have a big impact on the properties used.