【问题标题】:Spring boot config client propertiesSpring Boot 配置客户端属性
【发布时间】:2020-05-02 21:00:14
【问题描述】:
//This is the value of the property which needs to be fetched via config server from git repo
ConfigClientController(@Value("**${foo:test}"**) String value) {
    this.value = value;
}

上面的代码是一个spring cloud config客户端(spring.application.name=foo),它从git config repo获取配置属性。 Foo 是 foo.properties 中的属性。在这里,我对上面代码中的 :test 参数有点困惑。我想知道这个参数对于获取属性有什么意义。

【问题讨论】:

    标签: spring spring-boot-configuration


    【解决方案1】:

    如果foo 参数不存在意味着无法从配置中获取它,则将使用test 字符串。含义 - : 后面的内容是 @Value 注释参数的默认值。

    【讨论】:

      猜你喜欢
      • 2019-02-15
      • 1970-01-01
      • 2016-04-15
      • 2017-09-12
      • 2015-06-20
      • 2019-05-19
      • 2021-04-02
      • 2017-01-02
      • 2020-06-14
      相关资源
      最近更新 更多