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"/>

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