如何在 Cloud Foundry 使用 Spring 引导外部化配置

How to use Spring Boot externalized configuration at Cloud Foundry

对于 spring 引导应用程序中的外部化配置,我遵循 the standard way 在类路径中有一个 application.properties。然后,在生产环境中,我在 JAR 旁边放置了另一个 application.properties 来覆盖之前的 JAR。这样,我可以有一个 name 属性 在开发和生产环境中具有不同的值。

想知道在部署到 Cloud Foundry 时如何做同样的事情。

您可以简单地将要覆盖的属性设置为环境变量(将点替换为下划线,Boot 将匹配所有内容)。

您可能还想查看 Spring Cloud Config Spring project within Spring Cloud:

"Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring Environment but could be used by non-Spring applications if desired."