合并配置库

时间:2014-04-24 14:17:16

标签: java scala playframework typesafe typesafe-config

无论如何都要以下列方式合并两个配置文件:

val conf1= ....
val conf2= ....
conf1.withFallbackToPath(conf2,"root.branch2")

**conf1.conf**
root {
   branch1 {
      value="Hello i am source"
   }
}

**conf2.conf**
value = "I am merged"

此合并的结果应为:

root {
   branch1 {
      value="Hello i am source"
   }
   branch2 {
      value = "I am merged"
   }
}

1 个答案:

答案 0 :(得分:3)

conf2.atPath(" root.branch2&#34)。withFallback(CONF1)