【问题标题】:Importing another configuration file in Ktor 0.9.3 throws exception在 Ktor 0.9.3 中导入另一个配置文件会引发异常
【发布时间】:2019-01-18 19:12:47
【问题描述】:

在 Ktor 0.9.3 应用程序中,我希望为不同的环境提供不同的 .conf 文件,我在其中扩展了一个主要的 .conf 文件。但是,我收到以下异常:

Exception in thread "main" com.typesafe.config.ConfigException$NotResolved: called valueType() on value with unresolved substitutions, need to Config#resolve() first, see API docs
    at com.typesafe.config.impl.ConfigDelayedMerge.valueType(ConfigDelayedMerge.java:46)
    at com.typesafe.config.impl.SimpleConfig.hasPath(SimpleConfig.java:96)
    at io.ktor.config.HoconApplicationConfigKt.tryGetString(HoconApplicationConfig.kt:33)
    at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt:64)
    at io.ktor.server.engine.CommandLineKt$commandLineEnvironment$environment$1.invoke(CommandLine.kt)
    at io.ktor.server.engine.ApplicationEngineEnvironmentBuilder.build(ApplicationEngineEnvironment.kt:55)
    at io.ktor.server.engine.ApplicationEngineEnvironmentKt.applicationEngineEnvironment(ApplicationEngineEnvironment.kt:38)
    at io.ktor.server.engine.CommandLineKt.commandLineEnvironment(CommandLine.kt:50)
    at io.ktor.server.netty.DevelopmentEngine.main(DevelopmentEngine.kt:13)
    at ApplicationKt.main(application.kt:24)

这是我的application.conf 文件:

ktor {
    deployment {
        port = 8080
        port = ${?PORT}
        watch = [ website ]
    }
    application {
        modules = [ ApplicationKt.module ]
    }
}

ui {
  hotreload {
    enabled = false
    path-prefix = "http://localhost:3000"
  }
}

以及我想使用的扩展它:

include "application.conf"

ui.hotreload.enabled = true

任何想法出了什么问题以及如何解决它?

【问题讨论】:

  • 如何在 ktor pls 中使用多个配置文件?我想在每个环境中使用一个。

标签: kotlin typesafe-config ktor


【解决方案1】:

根据我在Ktor's GitHub 页面上打开的问题,这是一个已知的错误,PR fixing it 已经被合并,所以它应该在下一个版本中修复。事实上,它在版本0.9.4-alpha-2中按预期工作

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    相关资源
    最近更新 更多