【发布时间】:2017-07-31 20:02:23
【问题描述】:
我正在尝试从 conf 中获取文件路径,这是我的 conf 文件:
上传的文件路径.conf
file.path="public/img/"
这就是我在代码中从 conf 文件中获取路径的方式:
val conf = ConfigFactory.load()
var path : String = conf.getString("file.path")
我在第二行遇到异常
09:58:11.527 108649 [application-akka.actor.default-dispatcher-10] PlayDefaultUpstreamHandler 错误 - 无法调用操作 com.typesafe.config.ConfigException$WrongType:系统属性:路径 具有类型 OBJECT 而不是 STRING 在 com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:159) ~[com.typesafe.config-1.3.0.jar:na] 在 com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170) ~[com.typesafe.config-1.3.0.jar:na] 在 com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184) ~[com.typesafe.config-1.3.0.jar:na] 在 com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189) ~[com.typesafe.config-1.3.0.jar:na] 在 com.typesafe.config.impl.SimpleConfig.getString(SimpleConfig.java:246) ~[com.typesafe.config-1.3.0.jar:na]
我不知道自己做错了什么。
【问题讨论】:
标签: scala playframework-2.3 typesafe-config