【问题标题】:Exception while getting string from conf file in Play 2 with Scala在使用 Scala 的 Play 2 中从 conf 文件中获取字符串时出现异常
【发布时间】: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


    【解决方案1】:

    去掉引号

    file.path=public/img/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      • 2021-04-17
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多