简体   繁体   English

如何在命令行上覆盖typeafe配置列表值?

[英]How can I override a typesafe config list value on the command line?

I have an application.conf file with a structure like the following: 我有一个application.conf文件,其结构如下所示:

poller {
  datacenters = []
}

I would like to override "datacenters" on the command line. 我想在命令行上覆盖"datacenters"

For other configuration keys whose values are simple types (strings, numbers) I can override using -Dpath.to.config.value=<value> , and this works fine. 对于其值为简单类型(字符串,数字)的其他配置键,我可以使用-Dpath.to.config.value=<value>覆盖,这样可以正常工作。

However, I can't seem to find a way to do this for list s. 但是,我似乎找不到为列表 s做这个的方法。 In the example above, I tried to set "datacenters" to ["SJC", "IAD"] like so: -Dpoller.datacenters="['SJC', 'IAD']" , but I get an exception that the key value is a string, not a list. 在上面的例子中,我尝试将"datacenters"设置为["SJC", "IAD"]如下所示: -Dpoller.datacenters="['SJC', 'IAD']" ,但我得到一个例外的关键value是一个字符串,而不是一个列表。

Is there a way to signal to the typesafe config library that this value is a list? 有没有办法向typesafe配置库发信号通知这个值是一个列表?

在版本1.0.1中实现了另一种语法:

-Dpoller.datacenters.0=SJC -Dpoller.datacenters.1=IAD

I had the same issue some weeks ago, and finally dived into the source code to understand what's going on: 几个星期前我遇到了同样的问题,最后潜入源代码来了解发生了什么:

  • This feature is not implemented, it's not possible to define a list using command line argument 此功能未实现,无法使用命令行参数定义列表

Fixing it wouldn't be that hard, but someone need to take time to do it. 修复它不会那么难,但有人需要花时间去做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM