Kubernetes PropertySource 实现

配置 Spring Boot 应用程序的最常见方法是创建一个application.propertiesapplication.yaml或 一application-profile.propertiesapplication-profile.yaml文件,其中包含为 应用程序或 Spring Boot Starters。您可以通过指定系统属性或环境来覆盖这些属性 变量。spring-doc.cadn.net.cn

要启用此功能,您需要将spring.config.importapplication configuration 属性设置为kubernetes:(使用 YAML 时用引号转义,例如。"kubernetes:"). 目前,您无法指定要加载的 ConfigMap 或 Secretspring.config.import,默认情况下为 Spring Cloud Kubernetes 将基于spring.application.name财产。如果spring.application.name未设置,它将 加载名称为application.spring-doc.cadn.net.cn

如果您想加载 KubernetesPropertySourceS 的 S 与 3.0.x 版本之前的 3.0.x 版本类似 您可以添加spring-cloud-starter-bootstrap添加到应用程序的 Classpath 中,或者将spring.cloud.bootstrap.enabled=true作为环境变量。spring-doc.cadn.net.cn

不支持在 Bootstrap 期间加载属性(使用spring-cloud-starter-bootstrapspring.cloud.bootstrap.enabled=true并使用 Load 属性spring.config.import.您必须使用其中一种方法。