首页 > 解决方案 > 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?

标签: spring-bootspring-cloud-netflix

解决方案


最后,我找到了配置:

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

推荐阅读