【踩坑記錄】解決 Could not resolve placeholder 'xxx' in string value "${xxx}"

一般來說報Could not resolve placeholder 'xxx' in string value "${xxx}" 錯誤的原因都是由於項目中有多個地方的xml文件中用到了

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

或者是 

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

來引入配置文件,這時需要在這兩條配置後分別加上 

ignore-unresolvable="true"

p:ignoreUnresolvablePlaceholders="true"

來防止程序不能識別配置屬性。

也就是

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

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="true">

這樣配置文件中的屬性就能正確識別了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章