PropertyPlaceholderConfigurer配置

數的鮮爲人知方法都是因爲有着罕見的應用,就比如說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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章