Kubernetes PropertySource 实现
配置 Spring Boot 应用程序的最常见方法是创建一个application.properties
或application.yaml
或
一application-profile.properties
或application-profile.yaml
文件,其中包含为
应用程序或 Spring Boot Starters。您可以通过指定系统属性或环境来覆盖这些属性
变量。
要启用此功能,您需要将spring.config.import
application configuration 属性设置为kubernetes:
(使用 YAML 时用引号转义,例如。"kubernetes:"
).
目前,您无法指定要加载的 ConfigMap 或 Secretspring.config.import
,默认情况下为 Spring Cloud Kubernetes
将基于spring.application.name
财产。如果spring.application.name
未设置,它将
加载名称为application
.
如果您想加载 KubernetesPropertySource
S 的 S 与 3.0.x 版本之前的 3.0.x 版本类似
您可以添加spring-cloud-starter-bootstrap
添加到应用程序的 Classpath 中,或者将spring.cloud.bootstrap.enabled=true
作为环境变量。
不支持在 Bootstrap 期间加载属性(使用spring-cloud-starter-bootstrap 或spring.cloud.bootstrap.enabled=true 并使用 Load 属性spring.config.import .您必须使用其中一种方法。 |