我想在 cf push
之后使用名为 my_profile
的自定义配置文件启动我的 spring-boot 应用程序,但该应用程序始终使用默认配置文件启动 云
配置文件。如何指定要加载的确切配置文件?
我已经尝试像这样在 manifest.yml 中添加环境变量:
env:
SPRING_PROFILES_ACTIVE: my_profile
但是应用程序加载了两个配置文件(cloud
& my_profile
)
您是否有解决方案来仅加载我的自定义配置文件而不集成默认配置文件?
最佳答案
这来自 Java 构建包和 Spring 自动重新配置支持。
The Spring Auto-reconfiguration Framework adds the cloud profile to any existing Spring profiles such as those defined in the SPRING_PROFILES_ACTIVE environment variable.
要禁用此行为,您可以禁用 Spring 自动重新配置支持。
将环境变量 JBP_CONFIG_SPRING_AUTO_RECONFIGURATION
设置为 { enabled: false }
。
例如:
cf set-env my-cool-app JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{ enabled: false }'
请注意,这也会禁用 cloud.*
属性和自动重写 bean 以配置服务。
https://github.com/cloudfoundry/java-buildpack-auto-reconfiguration#what-is-auto-reconfiguration
关于java - 如何在 Cloud Foundry 中更改默认 Spring 配置文件 ("cloud"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56737584/