application.properties 中的 Spring 三元运算符

nor*_*lia 6 spring spring-boot

我想在 application.properties 上设置条件值,例如这有效:

info.dev.env=true info.environment=${info.dev.env:Production}

在这种情况下, if then 的值被用在elseinfo.dev.env != null上(无论它是 true 还是 false)。info.environmentProduction

这一切都很好,但我真正想要实现的是这样的:

info.dev.env=true info.isDevEnv=${info.dev.env?true:false} spring.thymeleaf.cache=${info.dev.env?false:true} spring.jpa.show-sql=${info.dev.env?true:false} etc...

因此,如果我明确设置任何内容, info.dev.env则使用三元运算符的左值,否则使用右值。

这个特定的示例与设置开发环境无关,我只是好奇是否有可能在 application.properties 中实现此类登录。