Spring导入多个properties文件

返回
Author Avatar
钢翼
2019-07-25
编程
201

当导入多个properties文件时,如果直接写多个

<context:property-placeholder location="classpath:conf/XXX1.properties" />
<context:property-placeholder location="classpath:conf/XXX2.properties" />

会只加载第一个配置文件。

解决方法是每一个context:property-placeholder都加上 ignore-unresolvable="true" 

<context:property-placeholder location="classpath:conf/XXX1.properties"  ignore-unresolvable="true" />
<context:property-placeholder location="classpath:conf/XXX2.properties" ignore-unresolvable="true" />