在开发过程中,通常为了将不同性质的配置信息写在不同的properties文件中,使用起来比较清晰易懂。那么在引用的时候也会有烦恼,普通情况下直接使用下面的方式
<context:property-placeholder location="classpath:jdbc.properties"/>
但如果存在多个则会在启动web容器的时候报错导致启动失败。因此,我们不得不做一些额外的配置进行说明是多个properties文件。
如果要在Spring配置文件中引用多个properties文件,则需要做以下处理:
<context:property-placeholder location="classpath:jdbc.properties" ignore-unresolvable="true"/>
<context:property-placeholder location="classpath:other.properties" ignore-unresolvable="true"/>
即添加
ignore-unresolvable="true"