|
对于最新稳定版本,请使用Spring Cloud Kubernetes 5.0.0! |
Kubernetes PropertySource 实现
配置 Spring Boot 应用最常见的方法是创建一个application.properties或application.yaml或
一application-profile.properties(应用配置文件.properties)或application-profile.yaml包含键值对的文件,这些对为你的
应用或春季Starters。你可以通过指定系统属性或环境来覆盖这些属性
变量。
要启用此功能,你需要设置spring.config.import应用配置属性Kubernetes:(使用 yaml 时用引号转义,例如“库伯内特斯:”).
目前你无法指定一个配置文件地图或密钥来加载spring.config.import,默认情况下是 Spring Cloud Kubernetes
将根据spring.application.name财产。如果spring.application.name不是设置的,它会
加载一个带有名称的ConfigMap和/或Secret应用.
如果你想加载Kubernetes,那就要地产来源在 bootstrap 阶段,就像 3.0.x 发布前一样有效
你可以选择添加Spring-cloud-starter-bootstrap映射到你的应用程序的类路径或集合spring.cloud.bootstrap.enabled=true作为环境变量。
不支持在 Bootstrap 期间加载属性(使用Spring-cloud-starter-bootstrap或spring.cloud.bootstrap.enabled=true以及载荷性质,使用spring.config.import.你必须采用其中一种方法。 |