`
zweichxu
  • 浏览: 132152 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

自定义spring cloud eureka client的instance-id

阅读更多

环境:spring cloud Finchley.RC2,spring boot 2.0.2.RELEASE,eureka 1.9.0

.properties文件增加如下配置:

eureka.instance.instance-id=${spring.cloud.client.ip-address}:${server.port}
eureka.instance.prefer-ip-address=true

 .yml文件则增加以下配置:

eureka:
  instance:
    instance-id: ${spring.cloud.client.ip-address}:${server.port}
    prefer-ip-address: true

 注意一点:

spring cloud Finchley.RC2及以后版本,spring.cloud.client.ipAddress改为了spring.cloud.client.ip-address,如果你还写成spring.cloud.client.ipAddress,将报如下错误:

Failed to bind properties under 'eureka.instance.instance-id' to java.lang.String:

    Property: eureka.instance.instance-id
    Value: ${spring.cloud.client.ipAddress}:${server.port}
    Origin: class path resource [application.yml]:22:18
    Reason: Could not resolve placeholder 'spring.cloud.client.ipAddress' in value "${spring.cloud.client.ipAddress}:${server.port}"

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics