List of usage examples for org.springframework.core.env PropertySources get
@Nullable PropertySource<?> get(String name);
From source file:com.github.dactiv.fear.commons.Apis.java
@Override public void afterPropertiesSet() throws Exception { PropertySourcesPlaceholderConfigurer configurer = null; PropertySources propertySources = null; try {//www. j a v a 2 s . co m configurer = applicationContext.getBean(PropertySourcesPlaceholderConfigurer.class); propertySources = configurer.getAppliedPropertySources(); } catch (Exception e) { LOGGER.warn("install " + PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME + " error", e); } if (propertySources == null) { return; } Field field = ReflectionUtils.findField(configurer.getClass(), "environment"); field.setAccessible(Boolean.TRUE); environment = (Environment) field.get(configurer); if (environment instanceof ConfigurableEnvironment) { ConfigurableEnvironment ce = (ConfigurableEnvironment) environment; MutablePropertySources sources = ce.getPropertySources(); PropertySource<?> ps = propertySources .get(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME); sources.addFirst(ps); } }