下面列出了怎么用org.springframework.core.env.EnumerablePropertySource的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.info("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.info("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.info("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.info("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.info("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.info("===========================================");
}
public Map<String, Map<String, Object>> getAllEnv() {
Map<String, Map<String, Object>> result = new LinkedHashMap<String, Map<String, Object>>();
for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
PropertySource<?> source = entry.getValue();
String sourceName = entry.getKey();
if (source instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
Map<String, Object> properties = new LinkedHashMap<String, Object>();
for (String name : enumerable.getPropertyNames()) {
properties.put(name, sanitize(name, enumerable.getProperty(name)));
}
result.put(sourceName, properties);
}
}
return result;
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
Object resolved = environment.getProperty(prop, Object.class);
if (resolved instanceof String) {
LOGGER.info("{} - {}", prop, environment.getProperty(prop));
} else {
LOGGER.info("{} - {}", prop, "NON-STRING-VALUE");
}
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.debug("====== Environment and configuration ======");
LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.debug("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.debug("====== Environment and configuration ======");
LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.debug("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.debug("===========================================");
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.debug("====== Environment and configuration ======");
LOGGER.debug("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> {
LOGGER.debug("{}", prop);
// Object resolved = environment.getProperty(prop, Object.class);
// if (resolved instanceof String) {
// LOGGER.info("{}", environment.getProperty(prop));
// }
});
LOGGER.debug("===========================================");
}
public Map<String, Map<String, Object>> getAllEnv() {
Map<String, Map<String, Object>> result = new LinkedHashMap<String, Map<String, Object>>();
for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
PropertySource<?> source = entry.getValue();
String sourceName = entry.getKey();
if (source instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
Map<String, Object> properties = new LinkedHashMap<String, Object>();
for (String name : enumerable.getPropertyNames()) {
properties.put(name, sanitize(name, enumerable.getProperty(name)));
}
result.put(sourceName, properties);
}
}
return result;
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment env = event.getApplicationContext().getEnvironment();
log.trace("====== Environment and configuration ======");
log.trace("Active profiles: {}", Arrays.toString(env.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) env).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.filter(prop -> !(prop.contains("credentials") || prop.contains("password")))
.forEach(prop -> log.trace("{}: {}", prop, env.getProperty(prop)));
log.info("===========================================");
log.info("Application [{} - version: {}, build time: {}] Started !",
buildProperties.getGroup() + ":" + buildProperties.getArtifact(),
buildProperties.getVersion(),
buildProperties.getTime());
log.info("===========================================");
}
/**
* Get property names from {@link EnumerablePropertySource}, and get property value from {@link ConfigurableEnvironment#getProperty(String)}
*/
private void getProperties(ConfigurableEnvironment environment, PropertySource<?> propertySource,
Map<String, Object> configFromSpringBoot) {
if (propertySource instanceof CompositePropertySource) {
// recursively get EnumerablePropertySource
CompositePropertySource compositePropertySource = (CompositePropertySource) propertySource;
compositePropertySource.getPropertySources().forEach(ps -> getProperties(environment, ps, configFromSpringBoot));
return;
}
if (propertySource instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource<?>) propertySource;
for (String propertyName : enumerablePropertySource.getPropertyNames()) {
try {
configFromSpringBoot.put(propertyName, environment.getProperty(propertyName, Object.class));
} catch (Exception e) {
throw new RuntimeException(
"set up spring property source failed.If you still want to start up the application and ignore errors, you can set servicecomb.config.ignoreResolveFailure to true.",
e);
}
}
return;
}
LOGGER.debug("a none EnumerablePropertySource is ignored, propertySourceName = [{}]", propertySource.getName());
}
/**
* Based on the following recommendation: https://github.com/spring-projects/spring-framework/issues/14874
*/
private Map<String, Object> getAllProperties() {
Map<String, Object> all = new HashMap<>();
if (environment instanceof ConfigurableEnvironment) {
for (PropertySource<?> propertySource : ((ConfigurableEnvironment) environment).getPropertySources()) {
if (propertySource instanceof EnumerablePropertySource) {
for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
if (key.startsWith(prefix)) {
all.put(key.substring(prefix.length()), propertySource.getProperty(key));
}
}
}
}
}
return all;
}
@Test
public void fromEnvironmentIsSuccessful() {
ConfigurableEnvironment mockEnvironment = mock(ConfigurableEnvironment.class);
MutablePropertySources propertySources = spy(new MutablePropertySources());
PropertySource mockVcapPropertySource = mock(EnumerablePropertySource.class);
when(mockEnvironment.getPropertySources()).thenReturn(propertySources);
doReturn(mockVcapPropertySource).when(propertySources).get(eq("vcap"));
when(mockVcapPropertySource.containsProperty(anyString())).thenReturn(true);
when(mockVcapPropertySource.getName()).thenReturn("vcap");
VcapPropertySource propertySource = VcapPropertySource.from(mockEnvironment);
assertThat(propertySource).isNotNull();
assertThat(propertySource.getSource()).isEqualTo(mockVcapPropertySource);
verify(mockEnvironment, times(1)).getPropertySources();
verify(propertySources, times(1)).get(eq("vcap"));
verify(mockVcapPropertySource, times(1))
.containsProperty(eq("vcap.application.name"));
verify(mockVcapPropertySource, times(1))
.containsProperty(eq("vcap.application.uris"));
}
public static Map<String, Object> getAllProperties(String prefix){
if(environment == null)init();
MutablePropertySources propertySources = ((ConfigurableEnvironment)environment).getPropertySources();
Map<String, Object> properties = new LinkedHashMap<String, Object>();
for (PropertySource<?> source : propertySources) {
if(source.getName().startsWith("servlet") || source.getName().startsWith("system")){
continue;
}
if (source instanceof EnumerablePropertySource) {
for (String name : ((EnumerablePropertySource<?>) source) .getPropertyNames()) {
boolean match = StringUtils.isEmpty(prefix);
if(!match){
match = name.startsWith(prefix);
}
if(match){
Object value = source.getProperty(name);
if(value != null){
properties.put(name, value);
}
}
}
}
}
return Collections.unmodifiableMap(properties);
}
@Override
public PollResult poll(boolean initial, Object checkPoint) throws Exception {
Map<String, Object> result = new HashMap<>();
environment
.getPropertySources()
.iterator()
.forEachRemaining(
source -> {
if (source instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
for (String key : enumerable.getPropertyNames()) {
result.putIfAbsent(key, enumerable.getProperty(key));
}
}
});
return PollResult.createFull(result);
}
SecretBeanPostProcessor(
ConfigurableApplicationContext applicationContext, SecretManager secretManager) {
this.applicationContext = applicationContext;
this.secretManager = secretManager;
MutablePropertySources propertySources =
applicationContext.getEnvironment().getPropertySources();
List<EnumerablePropertySource> enumerableSources = new ArrayList<>();
for (PropertySource ps : propertySources) {
if (ps instanceof EnumerablePropertySource) {
enumerableSources.add((EnumerablePropertySource) ps);
}
}
for (EnumerablePropertySource s : enumerableSources) {
propertySources.replace(s.getName(), new SecretAwarePropertySource(s, secretManager));
}
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void updateFlatConfig() {
super.updateFlatConfig();
if(this.environment instanceof ConfigurableEnvironment) {
ConfigurableEnvironment configurableEnv = ((ConfigurableEnvironment)environment);
for(PropertySource<?> propertySource : configurableEnv.getPropertySources()) {
if(propertySource instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource)propertySource;
for(String propertyName : enumerablePropertySource.getPropertyNames()) {
flatConfig.put(propertyName, enumerablePropertySource.getProperty(propertyName));
}
}
}
}
}
private Map<String, String> getAllKnownProperties(Environment env) {
Map<String, String> rtn = new HashMap<>();
if (env instanceof ConfigurableEnvironment) {
for (PropertySource<?> propertySource : ((ConfigurableEnvironment) env).getPropertySources()) {
if (propertySource instanceof EnumerablePropertySource) {
LOGGER.info("processing property source ::: " + propertySource.getName());
for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
String value = propertySource.getProperty(key).toString();
if (!StringUtils.isEmpty(value)) {
rtn.put(key, propertySource.getProperty(key).toString());
}
}
}
}
}
return rtn;
}
private Map<String, String> getAllKnownProperties(Environment env) {
Map<String, String> rtn = new HashMap<>();
if (env instanceof ConfigurableEnvironment) {
for (PropertySource<?> propertySource : ((ConfigurableEnvironment) env).getPropertySources()) {
if (propertySource instanceof EnumerablePropertySource) {
LOGGER.info("processing property source ::: " + propertySource.getName());
for (String key : ((EnumerablePropertySource) propertySource).getPropertyNames()) {
String value = propertySource.getProperty(key).toString();
LOGGER.debug("{} = {}", key, value);
if (!StringUtils.isEmpty(value) && !rtn.containsKey(key)) {
rtn.put(key, propertySource.getProperty(key).toString());
}
}
}
}
}
return rtn;
}
@Test
@SuppressWarnings("rawtypes")
public void propertyNameOrderingIsPreservedInEnvironment() {
final String[] expectedPropertyNames = new String[] { "foo", "baz", "enigma", "x.y.z", "server.url",
"key.value.1", "key.value.2", "key.value.3" };
EnumerablePropertySource eps = (EnumerablePropertySource) env.getPropertySources().get(
INLINED_PROPERTIES_PROPERTY_SOURCE_NAME);
assertArrayEquals(expectedPropertyNames, eps.getPropertyNames());
}
@SuppressWarnings("rawtypes")
@EventListener
public void handleContextRefresh(ContextRefreshedEvent event) {
final Environment environment = event.getApplicationContext().getEnvironment();
LOGGER.info("====== Environment and configuration ======");
LOGGER.info("Active profiles: {}", Arrays.toString(environment.getActiveProfiles()));
final MutablePropertySources sources = ((AbstractEnvironment) environment).getPropertySources();
StreamSupport.stream(sources.spliterator(), false).filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames()).flatMap(Arrays::stream).distinct()
.forEach(prop -> LOGGER.info("{}", prop));// environment.getProperty(prop)
LOGGER.info("===========================================");
}
public Map<String, Object> getEnv() {
Map<String, Object> result = new LinkedHashMap<String, Object>();
for (Entry<String, PropertySource<?>> entry : getPropertySources().entrySet()) {
PropertySource<?> source = entry.getValue();
if (source instanceof EnumerablePropertySource) {
EnumerablePropertySource<?> enumerable = (EnumerablePropertySource<?>) source;
for (String name : enumerable.getPropertyNames()) {
if(!result.containsKey(name)){
result.put(name, sanitize(name, enumerable.getProperty(name)));
}
}
}
}
return result;
}