在类型安全配置项目中复制application.conf

时间:2016-09-15 17:34:48

标签: scala typesafe-config

我正在阅读一些使用typesafe配置来读取资源文件夹中的application.conf文件的代码。我正在使用一个在其资源文件夹中有application.conf的库,我从另一个项目中调用该库,该项目在其资源文件夹中有自己的application.conf

typesafe配置是否能够分别读取正确的配置文件?

1 个答案:

答案 0 :(得分:2)

来自文档:

  

The substitution syntax ${foo.bar} will be resolved twice. First, all the reference.conf files are merged and then the result gets resolved. Second, all the application.conf are layered over the reference.conf and the result of that gets resolved again.

因此,两个库都会看到相同的Config,这是合并application.conf的结果(假设两者都使用默认行为,并且不再有application.conf或{{1} }类路径上的文件)。每个库不仅将其配置放在根目录中,而是拥有自己的配置树部分:即不

reference.conf

但是

debug = true
server = "example.com"

如果遵循此规则,则库不会发生冲突。如果他们使用具有不同含义的相同路径,您将遇到麻烦。

相关问题