context:property-placeholder

Spring多个占位符配置文件解析源码研究

主宰稳场 提交于 2019-12-01 20:40:33
Spring配置文件: <context:property-placeholder location="classpath:/settings.properties" /> <context:property-placeholder location="classpath:/conf.properties"/> settings.properties redis.masterName=mymaster conf.properties home.abroad=1 测试类: @Component public class PropertyPlaceHolderTest { @Value("${redis.masterName}") String masterName; @Value("${home.abroad}") int homeAbroad; public static void main(String[] args) { ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:applicationContext-test.xml"); PropertyPlaceHolderTest bean = ctx.getBean(PropertyPlaceHolderTest.class);