java - Dropwizard - 部署时,由于 yml 文件格式错误,应用程序无法运行
问题描述
我们正在尝试使用 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]
推荐阅读
- c# - 如何根据第一个列表框的选择让一个列表框呈现数据?
- docker - docker remote api 是否支持使用 docker-compose 文件创建容器?
- javascript - 为 for 循环添加超时
- android - 如何获取 Firebase 存储的 url 并将它们保存在 Arraylist Android 中
- ionic-framework - 如何在 scss 文件中使用 Ionic variables.scss $color?
- javascript - SVG 元素在 Edge 中动态更新后消失
- c - 在 Allegro5 中启用鼠标
- sql - 如何处理数据库表的日期时间列中的“NA”?
- python - 为什么在使用 psycopg2 时 INSERT INTO [local table] SELECT ... FROM [foreign data wrapper table] 会挂起?
- reactjs - 如何在 React 中的字符串变量中进行字符串插值?