Spring Boot 项目问题:while constructing a mapping found duplicate key api
- 在 Spring Boot 项目中,启动项目时,报如下错误
14:31:29.826 [main] ERROR org.springframework.boot.SpringApplication -- Application run failed
org.yaml.snakeyaml.constructor.DuplicateKeyException: while constructing a mappingin 'reader', line 1, column 1:server:^
found duplicate key apiin 'reader', line 24, column 1:api:^
# 翻译应用程序运行失败
发现重复的键 api
问题原因
-
这个错误是由于 YAML 配置文件中存在重复的键导致的
-
在 YAML 配置文件中,键必须是唯一的,不能重复定义
api: value1# 这是错误的
api: value2
处理策略
- 删除重复定义的键,确保在 YAML 配置文件中,键是唯一的