Spring中PropertyPlaceholderConfi gurer的使用
在使用Spring配置获取properties文件时,在网上查到相关的资料,分享哈!! (1)获取一个配置文件 <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfi gurer"> <property name="location"> <value>file:./mes.properties</value> </property> </bean>
其中classpath是引用src目录下的文件写法。
(2)获取多个配置文件时,配置就需要使用locations
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <value>classpath:/resources/jdbc.properties</value> <value>classpath:/resources/config.properties</value> </property> </bean> (3)使用多个PropertyPlaceholderConfi gurer来分散配置,达到整合多工程下的多个分散的Properties 文件,其配置如下:
<bean
<property
</bean>
<bean
</bean>
其中order属性代表其加载顺序,而ignoreUnresolvablePlaceh
PropertyPlaceholderConfi