首页 > 解决方案 > Spring Boot 配置客户端属性

问题描述

//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;
}

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

标签: springspring-boot-configuration

解决方案


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


推荐阅读