在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