Spring Cloud Eureka 服务注册列表显示 IP 配置问题

服务提供者向 Eureka 注册中心注册,默认以 hostname 的形式显示,Eureka 服务页面显示的服务是机器名:端口,并非IP+端口的形式 ,能够经过修改服务提供者配置本身的 IP 地址,并显示在 Eureka 的注册列表中。git

image

默认eureka.instance.instance-id 属性的配置是:github

${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}

能够自定义实例名配置:spring

spring.cloud.client.ipAddress=192.168.10.188 eureka.instance.prefer-ip-address=true eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${spring.application.name}:${server.port}
# eureka.instance.instance-id=${spring.cloud.client.ipAddress}:${server.port}

注:若是只是配置了eureka.instance.prefer-ip-address=true,不配置 eureka.instance.instance-id 那仍是显示 hostname,但 IP地址是能够访问的。app

REFER:
Spring Cloud Netflix Eureka: 多网卡环境下Eureka服务注册IP选择问题
https://blog.csdn.net/neosmith/article/details/53126924
Spring Cloud中,Eureka常见问题总结
http://itmuch.com/spring-cloud-sum-eureka/spa

相关文章
相关标签/搜索