Spring 中的宽松绑定真的不支持 @Value 注释吗?

wwe*_*ner 6 spring spring-boot spring-config

我们使用环境变量来配置 Spring Boot 应用程序中的各种属性。我发现FOO_BAR_BAZ通过@Value(${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-binding,https : //docs.spring .io/spring-boot/docs/1.4.3.RELEASE/reference/htmlsingle/#boot-features-external-config-vs-value

yam*_*enk 3

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