Spring Boot SimpleDiscoveryClient YAML configuration

649 Views Asked by At

I have a microservice serviceA that uses feign client to access another microservice.

During development, I want to rely on SimpleDiscoveryClient to get an instance of the service running in my docker daemon. If I configure spring.cloud.discovery.client.simple.instances.serviceA[0].uri=http://localhost:8081 then SimpleDiscoveryClient recognizes the serviceA and feign client works.

If I try to configure SimpleDiscoveryClient using yaml as below it doesn't recognize the service:

spring:
  cloud:
    discovery:
      client:
        simple:
          instances:
            serviceA:
              - uri: "http://localhost:8081"

This doesn't make sense to me.

I don't want to have an application.properties and application.yml just for that.

Am I missing something?

2

There are 2 best solutions below

0
littl3rud3 On
spring:
  cloud:
    discovery:
      client:
        simple:
          instances:
            serviceA[0]:
              uri: http://localhost:8081
0
Houcem Berrayana On

For the record please find a working example. I came across this question when trying to figure out the right configuration format.

spring:
  cloud:
    discovery:
      client:
        simple:
          instances:
            backend-service:
                - uri: http://localhost:9090
                - uri: http://192.168.110.50:8080