gpt4 book ai didi

spring-boot - YAML配置文件中的重复 key

转载 作者:行者123 更新时间:2023-12-03 15:25:00 28 4
gpt4 key购买 nike

在YAML中具有以下内容:

key1
key2: "value"

key1
key2
key3: "value2"

获取异常重复 key key1。
引起原因:org.yaml.snakeyaml.parser.ParserException:解析MappingNode时

尝试各种组合,但无法正确解析。

有人可以在这里提供帮助或指导。

谢谢

最佳答案

您的YAML在语法上是无效的,但我假设它实际上是这样的:

key1:
key2: "value"

key1:
key2:
key3: "value2"

您的错误是 key1两次用作根节点中的映射键。根据 YAML spec这是非法的:

The content of a mapping node is an unordered set of key: value node pairs, with the restriction that each of the keys is unique.



解决方案是使同一映射的所有键都唯一:
key11:
key2: "value"

key12:
key2:
key3: "value2"

关于spring-boot - YAML配置文件中的重复 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47668308/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com