微服务yml文件解析错误

parsing error in yml file for microservices

18:01:39.008 [main] 错误 org.springframework.boot.SpringApplication - 应用程序 运行 失败 org.yaml.snakeyaml.scanner.ScannerException: 此处不允许映射值 在 'reader',第 16 行,第 16 列: uri: lb://USER-SERVICE

`

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 无效。以 this validator 为例。

请注意第 16 行和下一行,uripredicatespath 与之前不在同一列。

有效的 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