在controller中無法通過注解@Value獲取到配置文件中定義的值


1. 默認的我們通常只在dao層用到jdbc的配置,然后使用到@Value注解獲取到值。

 這時候會在spring-dao掃描中加入下面配置

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

2. 如果想在controller中使用@Value指定變量,則還需要在springmvc中加入同樣的配置。

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM