学无先后,达者为师

网站首页 编程语言 正文

如何定义多个context:property-placeholder配置

作者:Terence Wang 更新时间: 2022-04-05 编程语言

今天在配置多配置文件的时候偶然发现如果我使用

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

<context:property-placeholder location="classpath:freemarker.properties"/>//这个进行多行编写配置文件的时候会出现后面那个文件出现读取不到的问题

这样会导致后面那个配置文件失效

原因:Spring 只会加载第一个context:property-placeholder配置后面的文件将不会再次进行加载,所以导致后面的文件读取不到

解决办法:

<context:property-placeholder ignore-unresolvable="true" location="classpath:jdbc.properties,classpath:filePath.properties"/>

加入一个ignore-unresolvable="true"属性,将文件用,隔开就可以了

原文链接:https://terence.blog.csdn.net/article/details/122646144

栏目分类
最近更新