bon*_*ash 3 config akka typesafe
我有一个配置文件:
app {
system {
action-type = "REST"
}
}
roles = [${app.system.action-type} "notifier"]
Run Code Online (Sandbox Code Playgroud)
我希望角色有一个值 [ RESTnotifier ],但这种方法给了我一个例外。有什么建议?
com.typesafe.config.ConfigException$NotResolved: need to Config#resolve() each config before using it, see the API docs for Config#resolve()
Run Code Online (Sandbox Code Playgroud)
您需要显式调用resolve上Config来说,如果你要使用替代的配置。一个简单的例子展示了这一点:
import com.typesafe.config.ConfigFactory
import collection.JavaConversions._
object ConfigExample extends App{
val cfgString = """
app {
system {
action-type = "REST"
}
}
roles = [${app.system.action-type}"notifier"]
"""
val cfg = ConfigFactory.parseString(cfgString).resolve()
println(cfg.getStringList("roles").toList)
}
Run Code Online (Sandbox Code Playgroud)
请注意对 的显式调用resolve。那应该可以解决您的问题。
| 归档时间: |
|
| 查看次数: |
1892 次 |
| 最近记录: |