Could not resolve placeholder 'jdbc.driver' in string value "${jdbc.driver}"問題

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是一樣的,並不能進行兩次掃描

  1. <context:property-placeholder location="classpath:config/resouce.properties"/>

  2. <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”

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

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

 

 

 

 

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