配置 Spring Boot 应用程序的最常见方法是创建一个 or 或
包含键值对的 OR 文件,这些键值对为您的
应用程序或 Spring Boot 启动器。您可以通过指定系统属性或环境来覆盖这些属性
变量。application.properties
application.yaml
application-profile.properties
application-profile.yaml
要启用此功能,您需要将应用程序配置属性设置为(使用 yaml 时用引号转义,例如。
目前,您无法指定要加载的 ConfigMap 或 Secret,默认情况下 Spring Cloud Kubernetes
将根据属性加载 ConfigMap 和/或 Secret。如果未设置,它将
加载名称为 的 ConfigMap 和/或 Secret。spring.config.import
kubernetes:
"kubernetes:"
spring.config.import
spring.application.name
spring.application.name
application
如果您想在引导阶段加载 Kubernetes s,就像它在 3.0.x 版本之前一样工作
您可以添加到应用程序的类路径中,也可以设置为环境变量。PropertySource
spring-cloud-starter-bootstrap
spring.cloud.bootstrap.enabled=true