【问题标题】:Pass an empty array to Dropwizard via command line通过命令行将一个空数组传递给 Dropwizard
【发布时间】:2018-01-11 02:15:08
【问题描述】:

我已在 Dropwizard 中使用此配置禁用请求访问日志记录:

server:
  requestLog:
    appenders: []

我想通过命令行覆盖它,但我不知道空数组的正确语法是什么。我试过-Ddw.server.requestLog.appenders=[]-Ddw.server.requestLog.appenders=-Ddw.server.requestLog.appenders='' 但都失败了:

  * Failed to parse configuration at: server.requestLog.appenders; Unexpected token (VALUE_STRING), expected FIELD_NAME: missing property 'type' that is to contain type id  (for class io.dropwizard.logging.AppenderFactory)
 at [Source: N/A; line: -1, column: -1] (through reference chain: metrics.Config["server"]->io.dropwizard.server.DefaultServerFactory["requestLog"]->io.dropwizard.request.logging.LogbackAccessRequestLogFactory["appenders"])

传递空数组的正确方法是什么?

【问题讨论】:

    标签: java arrays command-line command-line-arguments dropwizard


    【解决方案1】:

    我成功地将空数组传递给 Dropwizard 的方法是传递如下参数:

    -Ddw.server.requestLog.appenders=,
    

    , 是数组元素的分隔符,因此这会将两个空字符串传递给数组。在我的例子中,我有 3 个数组元素,所以我必须通过 ,,。我使用了 Dropwizard 2.0.8

    【讨论】:

      【解决方案2】:

      试试看。 \[\] 用于命令行中的空列表。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-11-29
        • 1970-01-01
        • 1970-01-01
        • 2016-11-05
        • 2011-03-04
        相关资源
        最近更新 更多