spring-bootspring-cloud-netflix

How to use eureka.client.service-url: property of netflix eureka in spring cloud


I am trying to add Eureka client in one of the microservices, but i am unable to figure out if how can I use the service-url.

I am using the Greenwich.SR1 version of spring-cloud.

Below is my application.yml

spring:
  application:
    name: stock-service

server:
  port: 9901

eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url: http://${eureka.instance.hostname}:9902/eureka/

I tried to search it out but everywhere I am getting the old way which is not supported in this version:

Old Way:

eureka:         #tells about the Eureka server details and its refresh time
  instance:
    leaseRenewalIntervalInSeconds: 1
    leaseExpirationDurationInSeconds: 2
  client:
    serviceUrl:
      defaultZone: http://127.0.0.1:8761/eureka/ 

Could someone help here?


Solution

  • Finally, I find the configuration:

    spring:
      application:
        name: stock-service
    
    server:
      port: 9901
    
    eureka:
      instance:
        hostname: localhost
      client:
        register-with-eureka: true
        fetch-registry: true
        service-url:
          default-zone: http://localhost:9902/eureka