【问题标题】:Is relaxed binding in Spring really unsupported for @Value annotations?@Value 注释真的不支持 Spring 中的轻松绑定吗?
【发布时间】:2018-01-16 00:39:47
【问题描述】:

我们使用环境变量来配置 Spring Boot 应用程序中的各种属性。我发现通过 @Value(${foo.bar.baz}) 绑定环境变量 FOO_BAR_BAZ 在 Spring Boot 1.4.3.RELEASE / Spring 4.3.5.RELEASE 中开箱即用。

但是,根据我在 [宽松绑定文档][1] 中阅读的内容,这似乎仅在 @ConfigurationProperties 中得到官方支持。

所以我的问题是,我是否必须期望观察到的行为(如上所述)在未来的版本中消失?

[1]:https://docs.spring.io/spring-boot/docs/1.4.3.RELEASE/reference/htmlsingle/#boot-features-external-config-relaxed-bindinghttps://docs.spring.io/spring-boot/docs/1.4.3.RELEASE/reference/htmlsingle/#boot-features-external-config-vs-value

【问题讨论】:

    标签: spring spring-boot spring-config


    【解决方案1】:

    一些简单的宽松绑定似乎可以与@Value 一起使用。查看以下讨论以获取更多信息:https://github.com/spring-projects/spring-boot/issues/4413

    【讨论】:

      猜你喜欢
      • 2011-02-19
      • 2018-01-17
      • 2013-07-22
      • 2012-02-25
      • 2015-05-19
      • 2011-07-23
      • 1970-01-01
      • 2014-10-22
      • 2018-10-23
      相关资源
      最近更新 更多