<context:property-placeholderlocation>标签导入多个文件

先上错误代码

#MyBatis.xml
<context:property-placeholder location="classpath:jdbc.properties" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
</bean>
#redis.xml
<context:property-placeholder location="classpath:redis.properties" />
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
</bean>

spring mvc整合redis时新增了一个redis.xml配置文件,该配置文件中使用<context:property-placeholderlocation>读取properties文件,结果发现不行,一直读取不到。
原来是因为<context:property-placeholderlocation>标签只能在spring配置文件中存在一份,改为如下解决:

<context:property-placeholder location="classpath:jdbc.properties, classpath:redis.properties" />

参考链接:https://my.oschina.net/u/2326864/blog/1619107

posted @ 2020-09-22 15:49  永恒的恒  阅读(696)  评论(0)    收藏  举报