如果设置了某些环境变量,我想有条件地替换值。
例如
spring:
profiles:
include:
- 'base'
- 'FOO' (only if `FOO` is set to true in env variable)
最佳答案
YAML 中没有条件逻辑,但如果您愿意将值放入环境变量中 - 您可以这样做:
spring:
profiles:
include: ${MY_FOO_ENV:base}
将 MY_FOO_ENV 设置为“FOO”。如果环境中未定义 MY_FOO_ENV,则 ':base' 设置默认值。
关于java - yml配置中的spring boot spring EL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53622149/