一般來說報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">
這樣配置文件中的屬性就能正確識別了。