Pureconfig - 是否可以在 conf 文件中包含另一个 conf 文件?

Pureconfig - is it possible to include in conf file another conf file?

是否可以在 *conf 文件中包含另一个 conf 文件?

当前实施:

// db-writer.conf
writer: {
  name="DatabaseWriter",
  model="model1",
  table-name="model1",
  append=false,
  create-table-file="sql/create_table_model1.sql",
  source-file="abcd.csv"
}

所需的解决方案:

// model1.conf + others model2.conf, model3.conf..
table: {
 name="model1",
 table-name="model1",
 create-table-file="../sql/create_table_model1.sql"
}

//db-writer.conf
import model1.conf       <=== some import?
writer: {
  name="DatabaseWriter",
  model="model1",        <=== some reference like this?
  append=false,
  source-file="abcd.csv"
}

我想要这样的原因是:

我想这是不可能的 - 如果不可能,您对如何分离配置和重用它们有什么建议吗?

我正在使用 scala 2.12 lang 和 pureconfig 0.14(可以更新到任何更新版本)

Pureconfig 使用 HOCON(尽管对持续时间等事物的某些解释有所不同)。支持 HOCON include

因此,假设您的资源中有 model1.conf(例如 src/main/resources),您在 db-writer.conf 中所需要的只是

include "model1"

还支持 HOCON 样式的覆盖和串联:

writer: ${table} {
  name = "DatabaseWriter"
  model = "model1"
  append = false
  source-file = "abcd"
}