Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 432
Shivang Agarwal Avatar asked Dec 31 '22 22:12

Shivang Agarwal


1 Answers

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
like image 134
Shivang Agarwal Avatar answered Jan 04 '23 17:01

Shivang Agarwal