spring-boot - 微服务的 yml 文件中的解析错误
问题描述
18:01:39.008 [main] 错误 org.springframework.boot.SpringApplication - 应用程序运行失败 org.yaml.snakeyaml.scanner.ScannerException:在“阅读器”第 16 行第 16 列中不允许映射值:uri:lb ://用户服务
`
server:
port: 9190
spring:
application:
name: API-Gateway
cloud:
gateway:
routes:
- id: user-service
uri: lb://DEPT-SERVICE
predicates:
- path=/user/**
- id: dept-service
uri: lb://USER-SERVICE
predicates:
- path=/departments/**
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
preferIpAddress: true
`
解决方案
您的 yaml 无效。检查此验证器作为示例。
请注意第 16 行和下一行uri
,predicates
和 与path
之前不在同一列上。
有效的 yaml 是:
server:
port: 9190
spring:
application:
name: API-Gateway
cloud:
gateway:
routes:
- id: user-service
uri: lb://DEPT-SERVICE
predicates:
- path=/user/**
- id: dept-service
uri: lb://USER-SERVICE
predicates:
- path=/departments/**
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
preferIpAddress: true
推荐阅读
- python - 在我的数据框上应用 PCA 后,它给了我一个奇怪的数字,它是什么意思或我该如何解释它?
- python - 从具有堆叠价格的数据框中计算股票收益
- c++ - 具有分段错误的函数模板
- c# - 如何动态地将行添加到自适应卡?
- sql - 将长数字导出到 Excel 的 CSV 文件
- c# - GenerateRadioButton() 问题
- opencascade - OpenCASCADE 教程中 `BRepLib::BuildCurves3d` 调用的目的是什么?
- hibernate - SpringBoot @Transactional 在异常后不刷新会话
- spring - 无法写入 JSON:无限递归
- android - 如何在 PyTorch Mobile 上将张量转换为位图?