Currently, EnvironmentEndpoint shows where all of PropertySources are coming from including duplicated keys(overrides) if they are from different sources. (e.g.: one from application.yaml and same key from application-<profile>.yaml)
Usually, while troubleshooting or debugging, what people want to find out is the final value resolved by the Environment.(actual value resolved by @Value("x.y.z") etc.)
Current /env can serve the purpose, but may need to go through several hoops to get the correct answer if there are overrides.
Having final property key-values as part of EnvironmentEndpoint would give clear answer what key-values are used in application.
Such property sources considering override can be obtained like this:
Map<String, Object> map = new HashMap<>();
for (PropertySource<?> propertySource : ((ConfigurableEnvironment) this.environment).getPropertySources()) {
if (propertySource instanceof EnumerablePropertySource) {
for (String key : ((EnumerablePropertySource<?>) propertySource).getPropertyNames()) {
map.putIfAbsent(key, propertySource.getProperty(key));
}
}
}
// may sort the map with key...
Currently,
EnvironmentEndpointshows where all ofPropertySourcesare coming from including duplicated keys(overrides) if they are from different sources. (e.g.: one fromapplication.yamland same key fromapplication-<profile>.yaml)Usually, while troubleshooting or debugging, what people want to find out is the final value resolved by the
Environment.(actual value resolved by@Value("x.y.z")etc.)Current
/envcan serve the purpose, but may need to go through several hoops to get the correct answer if there are overrides.Having final property key-values as part of
EnvironmentEndpointwould give clear answer what key-values are used in application.Such property sources considering override can be obtained like this: