无法从 Akka ActorSystem 获取配置值

Can't get config value from Akka ActorSystem

当我使用 println(system.settings.config.root().values()) 打印当前配置值时 我得到了很长的值列表,被截断了:

[SimpleConfigObject({"separator":":"}), SimpleConfigObject({"home":"/usr/local/Cellar/typesafe-activator/1.3.10"}), , SimpleConfigObject({"country":{"format":"UA"},"dir":"/Users/sr/ScalaProjects/akka-http-test","home":"/Users/sr","language":"en","name":"sr"})]

我想获取 "dir" 键的值。 我尝试这样做:

system.settings.config.getValue("dir")

但出现异常:

com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'dir'

如何获得这个密钥?

您可能在访问 dir 之前错过了访问 user

system.settings.config.getConfig("user").getValue("dir")

请注意,您在打印 root().values() 时并未打印配置键,因此您看不到 "user" 键。您应该能够通过打印(例如)

来查看完整的配置块
println(system.settings.config.root().entrySet())