前言:最近在做一个项目,想要在 controller 层直接通过注解 @Value("")来获取 properties 里面配置的属性。

  这个其实和 springmvc、spring 两个容器相关。controller 是在 springmvc 容器中,所以需要看看 springmvc 的配置文件中是否有配置 properties 文件。

  经设置,即可在 controller 层使用 @Value 了。

    <!-- 加载配置文件,controller中需要使用@Value得到配置值 -->
    <context:property-placeholder location="classpath*:conf/system/*.properties"/>

 

  参考:http://www.cnblogs.com/hafiz/p/5875740.html

相关文章:

  • 2022-12-23
  • 2021-06-09
  • 2022-01-11
  • 2021-08-25
  • 2022-12-23
  • 2021-07-11
  • 2021-07-31
  • 2021-07-12
猜你喜欢
  • 2021-08-09
  • 2021-06-17
  • 2021-06-02
  • 2021-08-24
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
相关资源
相似解决方案