Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"問題
applicationContext 加載properties類型的配置文件的問題
錯誤提示:
Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"
錯誤緣由
在配置文件中,使用2次引入配置文件的掃描,但是兩次掃描的key是一樣的,並不能進行兩次掃描
-
<context:property-placeholder location="classpath:config/resouce.properties"/>
-
<context:property-placeholder location="classpath:config/db.properties"/>
解決方法1
將配置文件寫到一個方法裏,用 “,” 隔開
<context:property-placeholder location="classpath:config/db.properties,classpath:config/resouce.properties"/>
- 解決方法2
在每個掃描的配置文件後加上 ignore-unresolvable=”true”
-
<context:property-placeholder location="classpath:config/resouce.properties" ignore-unresolvable="true"/>
-
<context:property-placeholder location="classpath:config/db.properties" ignore-unresolvable="true"/>