【问题标题】:What is indexed array in YAML?YAML 中的索引数组是什么?
【发布时间】:2021-08-04 03:01:55
【问题描述】:

在我的 yaml spring-boot 应用程序配置中

additional-properties[auto.register.schemas]: false
additional-properties[use.latest.version]: true

它有效!我在 YAML 规范中没有找到这种语法。这是什么意思?如何使用标准 YAML 重写它?和这个一样吗

additional-properties:
    - auto.register.schemas: false
    - use.latest.version: true

?

【问题讨论】:

  • 根据文档,这可能是map binding。这肯定是 YAML 不知道的。您能否详细说明如何“它是如何工作的”?

标签: yaml


【解决方案1】:

阿法伊克: 每个元素(用点分隔)都必须在自己的行上并相应地制表。

foo:
   bar:
       name: value
       name2: value2
   fez: value

所以你的例子是:

additional-properties:
    auto:
       register:
           schemas: false

【讨论】:

  • 这不是真的,至少对于 Spring application.yaml 来说不是。第二部分也不是真的,看我的回答。
【解决方案2】:

经过实验并找到this answer后,我得出结论(至少在春季application.yaml):

camel.component.kafka:
         additional-properties[auto.register.schemas]: false
         additional-properties[use.latest.version]: true

等价于

camel.component.kafka.additional-properties:
            "[auto.register.schemas]": false
            "[use.latest.version]": true

这相当于

camel:
   component:
      kafka:
         additional-properties:
            "[auto.register.schemas]": false
            "[use.latest.version]": true

【讨论】:

    猜你喜欢
    • 2016-11-04
    • 2014-10-13
    • 2021-03-29
    • 1970-01-01
    • 1970-01-01
    • 2013-02-08
    • 2011-02-26
    • 2011-08-17
    • 1970-01-01
    相关资源
    最近更新 更多