【问题标题】:Dropwizard - On deployment, application fails to run due to a malformed yml fileDropwizard - 部署时,由于 yml 文件格式错误,应用程序无法运行
【发布时间】:2019-11-22 19:41:19
【问题描述】:

我们正在尝试使用 Dropwizard 指标将自动化指标添加到我们的 Java 应用程序中。到目前为止,config.yml 文件如下所示:

metrics:
  reporters:
  - type: log
    logger: metrics
    frequency: 5 minute
    includes: "io.dropwizard.jetty.MutableServletContextHandler.active-requests","io.dropwizard.jetty.MutableServletContextHandler.active-dispatches","io.dropwizard.jetty.MutableServletContextHandler.active-suspended"

运行此项目时,我们收到一条错误消息,指出 yaml 文件格式错误:

io.dropwizard.configuration.ConfigurationParsingException: test/config.yml has an error:
  * Malformed YAML at line: 24, column: 82; while parsing a block mapping
 in 'reader', line 20, column 5:
      - type: log
        ^
expected <block end>, but found FlowEntry
 in 'reader', line 23, column 81:
     ... tContextHandler.active-requests","io.dropwizard.jetty.MutableSer ...
                                         ^

这里写 yaml 的方式到底有什么问题?我的理解是缩进、空格和引号内没有逗号是正确的,我们无法找到任何其他问题。

【问题讨论】:

标签: java format dropwizard metrics


【解决方案1】:

只需将第 6 行更改为

includes: [io.dropwizard.jetty.MutableServletContextHandler.active-requests,io.dropwizard.jetty.MutableServletContextHandler.active-dispatches,io.dropwizard.jetty.MutableServletContextHandler.active-suspended]

【讨论】:

    猜你喜欢
    • 2013-07-29
    • 2014-06-01
    • 1970-01-01
    • 2021-04-18
    • 2018-03-15
    • 2020-10-30
    • 1970-01-01
    • 2020-02-17
    • 1970-01-01
    相关资源
    最近更新 更多