Dropwizard - 在部署时,由于 yml 文件格式错误,应用程序无法 运行

Dropwizard - On deployment, application fails to run due to a malformed yml file

我们正在尝试使用 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的写法到底有什么问题?我的理解是缩进、空格和引号内没有逗号是正确的,我们找不到任何其他问题。

只需将第 6 行更改为

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