gpt4 book ai didi

scala - com.typesafe.config.ConfigException$NotResolved : has not been resolved,

转载 作者:行者123 更新时间:2023-12-02 06:15:37 24 4
gpt4 key购买 nike

我正在尝试使用类型安全配置读取以下配置文件

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”时才会出现错误

最佳答案

我自己解决了。

ConfigFactory.parseFile(new File("src/main/resources/application.conf")).resolve()

关于scala - com.typesafe.config.ConfigException$NotResolved : has not been resolved,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41528547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com