日期:2014-05-20  浏览次数:20782 次

Spring 如何读取properties文件
如题 谢谢

------解决方案--------------------
BeanDefinitionRegistry reg = new DefaultListableBeanFactory();
 PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(reg);
 reader.loadBeanDefinitions(new ClassPathResource("beanConfig.properties"));
 BeanFactory factory = (BeanFactory)reg;


或者


<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>src/jdbc.properties</value>
</property>
</bean>