Spring加載property文件

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location" value="classpath:db.properties"/>
    <!--指定外部屬性文件的編碼格式-->
    <property name="fileEncoding" value="UTF-8"></property>
</bean>

  <context:property-placeholder location="classpath:db.properties"/>

<context:property-placeholder location="classpath:db.properties,
classpath:db.properties"/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfi
gurer">  
      <property name="locations">  
         <list>  
            <!-- 這裏支持多種尋址方式:classpath和file -->  
            <value>classpath:/opt/demo/config/demo-db.properties</value>  
            <!-- 推薦使用file的方式引入,這樣可以將配置和代碼分離 -->  
            <value>file:/opt/demo/config/demo-mq.properties</value>  
            <value>file:/opt/demo/config/demo-remote.properties</value>  
         </list>  
      </property>  
 
  </bean>  

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfi
gurer">  
      <property name="locations">  
         <list>  
            <!-- 這裏支持多種尋址方式:classpath和file -->  
            <value>classpath:/opt/demo/config/demo-db.properties</value>  
            <!-- 推薦使用file的方式引入,這樣可以將配置和代碼分離 -->  
            <value>file:/opt/demo/config/demo-mq.properties</value>  
            <value>file:/opt/demo/config/demo-remote.properties</value>  
         </list>  
      </property>  
 
  </bean>







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