【发布时间】:2017-01-08 01:38:08
【问题描述】:
我正在尝试使用类型安全配置读取以下配置文件
common = {
jdbcDriver = "com.mysql.jdbc.Driver"
slickDriver = "slick.driver.MySQLDriver"
port = 3306
db = "foo"
user = "bar"
password = "baz"
}
source = ${common} {server = "remoteserver"}
target = ${common} {server = "localserver"}
当我尝试使用此代码读取我的配置时
val conf = ConfigFactory.parseFile(new File("src/main/resources/application.conf"))
val username = conf.getString("source.user")
我收到一个错误
com.typesafe.config.ConfigException$NotResolved: source.user has not been resolved, you need to call Config#resolve(), see API docs for Config#resolve()
如果我将所有内容都放在“源”或“目标”标签中,我不会收到任何错误。只有当我尝试使用“common”时才会出现错误
【问题讨论】:
标签: scala typesafe-config