-
Notifications
You must be signed in to change notification settings - Fork 41.7k
Open
Description
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...Metadata
Metadata
Assignees
Labels
type: enhancementA general enhancementA general enhancement