Configuration 如何从typesafe配置对象中删除节?

Configuration 如何从typesafe配置对象中删除节?,configuration,typesafe,Configuration,Typesafe,如何从typesafe配置中删除节 下面是一个简化的问题- import com.typesafe.config.{ConfigFactory, Config} val configStr: String = """{ section1 { s1Val1 = "a" } section2 { s2Val1 = "b" } }""" val overrideConfigStr : String = """{ section2 { s2Val2 = "

如何从typesafe配置中删除节

下面是一个简化的问题-

import com.typesafe.config.{ConfigFactory, Config}

val configStr: String = """{
  section1 {
    s1Val1 = "a"
  }
  section2 {
    s2Val1 = "b"
  }
}"""

val overrideConfigStr : String = """{
  section2 {
    s2Val2 = "bPrime"
  }
}"""

val myConfig : Config = ConfigFactory.parseString(configStr)

def removeConfigSection(config: Config, sectionHead: String): Config = ???

val overrideConfig : Config = ConfigFactory.parseString(overrideConfigStr)

val newConfigWithOverride = removeConfigSection(myConfig, 
      "section2").withFallback(overrideConfig)
就像“section2”的情况一样,我希望获取一个大的配置文件,并用一些自定义节覆盖许多节。如何实现def removeConfigSection(配置:配置,节头:字符串)?

您可以使用:

def removeConfigSection(配置:配置,节头:字符串):配置=
不带路径的配置(节头)

只要确保正确引用
路径