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

 

posted @ 2018-01-10 20:41  me-ht  阅读(283)  评论(0编辑  收藏  举报