【问题标题】:Unable to run Scala Play app throwing com.typesafe.config.ConfigException$Missing: No configuration setting found for key无法运行 Scala Play 应用程序抛出 com.typesafe.config.ConfigException$Missing:找不到密钥的配置设置
【发布时间】:2018-07-15 22:12:56
【问题描述】:

我正在尝试运行 Scala Play 应用程序并遇到此异常:

Caused by: com.typesafe.config.ConfigException$Missing: No configuration setting found for key 'memo'
at com.typesafe.config.impl.SimpleConfig.findKeyOrNull(SimpleConfig.java:152) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.findOrNull(SimpleConfig.java:170) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:184) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.find(SimpleConfig.java:189) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.getObject(SimpleConfig.java:264) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:270) ~[config-1.3.1.jar:na]
at com.typesafe.config.impl.SimpleConfig.getConfig(SimpleConfig.java:37) ~[config-1.3.1.jar:na]
at lila.common.PlayApp$.loadConfig(PlayApp.scala:24) ~[na:na]
at lila.memo.Env$.lila$memo$Env$$$anonfun$1(Env.scala:28) ~[na:na]
at lila.common.Chronometer$.sync(Chronometer.scala:56) ~[na:na]

我把外部引用放到了配置文件中,比如:

run -Dconfig.resource=conf/base.conf

我是 Scala 的新手。试图找出 conifg-1.3.1-jar 但无法找到。您能否建议如何克服这种情况。

**在 base.conf 中存在备忘录的配置。

【问题讨论】:

    标签: scala playframework


    【解决方案1】:

    尝试不使用conf/,运行 -Dconfig.resource=base.conf

    来自 Play 2.6 文档

    Using-Dconfig.resource

    这将在应用程序类路径中搜索替代配置文件(您通常在打包之前将这些替代配置文件提供到您的应用程序 conf/ 目录中)。 Play 会查看 conf/因此您不必添加 conf/

    $ /path/to/bin/ -Dconfig.resource=prod.conf

    Using-Dconfig.file

    您还可以指定另一个未打包到应用程序工件中的本地配置文件:

    $ /path/to/bin/ -Dconfig.file=/opt/conf/prod.conf

    如果您从 Intellij 配置 sbt 任务,您必须 quote 整个命令。

    “运行 -Dconfig.resource=prod.conf”

    【讨论】:

    • 添加您正在使用 conf 的行和 conf 本身。
    • 你是直接使用 Intellij 还是 sbt 控制台?
    • 我已经更新了答案,如果你使用 Intellij,你必须引用命令
    • 问题已解决。可能是 sbt 的问题。使用 Intellij 可以很好地与 Dconfig 配合使用。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-28
    • 2015-09-04
    • 2021-08-25
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2017-09-25
    相关资源
    最近更新 更多