首页 > 技术文章 > 在application-context.xml中配置多个property-placeholder

deolin 2017-09-10 17:45 原文

如下所示,直接写多个<context:property-placeholder>标签是会报错的。

    <context:property-placeholder location="classpath:wechat/official-account.properties" />
    <context:property-placeholder location="classpath:db.properties" />

 

即便是写在不同的xml里面,只要最终被application-context.xml的<import>标签所引入,都是会报错的。

正确的做法追加一个ignore-unresolvable属性,每个property-placeholder都需要加。

    <context:property-placeholder location="classpath:wechat/official-account.properties" ignore-unresolvable="true" />
    <context:property-placeholder location="classpath:db.properties" ignore-unresolvable="true" />

 

推荐阅读