Skip to content

Instantly share code, notes, and snippets.

@rbaul
Created September 7, 2022 10:53
Show Gist options
  • Save rbaul/76b322b18705429899d440e6eb2b2f5a to your computer and use it in GitHub Desktop.
Save rbaul/76b322b18705429899d440e6eb2b2f5a to your computer and use it in GitHub Desktop.
Get all environment in Spring Boot Application
Map<String, Object> map = new HashMap();
for(Iterator it = ((AbstractEnvironment) env).getPropertySources().iterator(); it.hasNext(); ) {
PropertySource propertySource = (PropertySource) it.next();
if (propertySource instanceof MapPropertySource) {
map.putAll(((MapPropertySource) propertySource).getSource());
}
}
return map;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment