Search code examples
spring-bootmicroservicesnetflix-eureka

parsing error in yml file for microservices


18:01:39.008 [main] ERROR org.springframework.boot.SpringApplication - Application run failed org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here in 'reader', line 16, column 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

`


Solution

  • Your yaml is not valid. Check this validator as example.

    Note how on line 16 and next, uri, predicates and path are not on the same column as just before.

    Valid yaml is:

    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