spring讀取多個properties文件

項目中可能出現多個properties文件,比如數據庫的jdbc.properties,redis的redis.properties等

在spring的配置文件中可以有兩種方法讀取properties文件

===============================分割線===================================

一,

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
<property name="locations">
<list>
  <value>classpath:redis/redis-config.properties</value>

  <value>classpath:database/jdbc.properties</value>

</list>
</property>
</bean>

========================分割線===================================

二,

 <context:property-placeholder location="classpath:database/jdbc.properties" ignore-unresolvable="true"/>

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