我们有一个项目,其中包含使用hocon配置构建的大型配置文件。 有意在可能的情况下使用变量来创建template_section,并根据某些选项在模板中设置一些值。
问题在于,在此配置中使用variables
时,我必须始终引用绝对路径。
有可能以某种方式使用规范名称(如果属性位于同一级别)?
示例:
foo {
bar = 4
baz = ${foo.bar} // work perfect
baz = ${[this].bar} // can I do smth like that? Any ideas.
}
更真实的例子。我实际上正在寻找的是建立hocon配置的一般OOP能力。
我有一些内部template_config
的父配置important_option
真正依赖于实现:
custom_config1
或custom_config2
,我目前要做的是在两个子配置中实现important_option
,因为绝对路径我必须引用自定义配置选择名称。
custom_config1: $template_config {
child_option = child_value1
}
custom_config2: $template_config {
child_option = child_value2
}
template_config {
important_option = ${child_option} // NOT POSSIBLE
child_option = not_implemented
}