多數的鮮爲人知方法都是因爲有着罕見的應用,就比如說Spring中PropertyPlaceholderConfigurer這個類,它是用來解析Java Properties屬性文件值,並提供在spring配置期間替換使用屬性值。接下來讓我們逐漸的深入其配置。
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/reportConfig.properties</value>
</property>
<property name="fileEncoding" value="utf-8"/>
</bean>
1.<bean id="configBean" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
2. <property name="locations">
3. <list>
4. <value>classpath*:properties1.properties</value>
5. <value>properties2.properties</value>
6. <value>properties3.properties</value>
7. </list>
8. </property>
9.</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:c:/reportConfig.properties</value>
</property>
<property name="fileEncoding" value="utf-8"/>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:c:/reportConfig.properties</value>
</property>
<property name="fileEncoding" value="utf-8"/>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<bean class="java.lang.System" factory-method="getenv">
<constructor-arg value="CIRC_REPORT"/>
</bean>
</property>
<property name="fileEncoding" value="utf-8"/>
</bean>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
<property name=”ignoreResourceNotFound” value=”true”/>
<property name="location">
<value>${CIRC_REPORT}</value>
</property>
<property name="fileEncoding" value="utf-8"/>
< /bean>