在 playframework 中包含环境特定文件

include environment specific file in playframework

是否可以在 application.conf 文件中实现?

env = ${?ENV}".auth.conf" 
include env

'include' 语句不接受环境。据我所知,我只能将一个字符串传递给 include,例如:

include "dev.auth.conf"

有没有办法为 'include' 语句指定一个 variable

不,那不可能。

来自HOCON spec

Value concatenation is NOT performed on the "argument" to include or url() etc. The argument must be a single quoted string. No substitutions are allowed, and the argument may not be an unquoted string or any other kind of value.

假设的特征很复杂。

a = ${b}
b = 1

解析为 a = 1。在那个模式中,

include ${b}.conf
b = 1

应该包括1.conf.

但是如果 b = 1 定义在另一个包含中怎么办?是

include filehavingb.conf
include ${b}.conf

不同于

include ${b}.conf
include filehavingb.conf

和其他并发症。

无论如何,https://github.com/typesafehub/config/issues/122

讨论了这个问题

目前获得类似结果的最简单方法是使用 -Dconfig.file