你需要类似的东西,也许可以改进。这是第一次尝试:
...import org.springframework.core.env.PropertySource;import org.springframework.core.env.AbstractEnvironment;import org.springframework.core.env.Environment;import org.springframework.core.env.MapPropertySource;...@Configuration...@org.springframework.context.annotation.PropertySource("classpath:/config/default.properties")...public class GeneralApplicationConfiguration implements WebApplicationInitializer { @Autowired Environment env; public void someMethod() { ... 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()); } } ... }...基本上,环境的所有内容
MapPropertySource(并且有很多实现)都可以作为Map属性来访问。



