這個在spring中配置文件中是非常常用的。
一、context:property-placeholder大大的方便了我們一些配置的加載,尤其是數據庫方面


同樣也方便了我們系統中的一些設置:


二、ignore-unresolvable
同個模塊中如果出現多個context:property-placeholder ,location properties文件后,運行時出現Could not resolve placeholder 'key' in string value${key}。原因是在加載第一個context:property-placeholder時會掃描所有的bean,而有的bean里面出現第二個 context:property-placeholder引入的properties的占位符${key},此時還沒有加載第二個property-placeholder,所以解析不了${key}。
解決:
辦法一,可以將通過模塊的多個property-placeholder合並為一個,將初始化放在一起。
方法二,添加ignore-unresolvable="true",這樣可以在加載第一個property-placeholder時出現解析不了的占位符進行忽略掉。
