Spring cloud 显示 INSTANCE-ID 如果以IP + 端口号的形式显示,会更清析的定位每个服务所在的机器节点的状态。

依赖的 pom

1
2
3
4
5
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-commons</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>

yml 相关配置

1
2
3
4
5
6
7
eureka:
client:
service-url:
defaultZone: http://10.168.16.101:8761/eureka/
instance:
instance-id: ${spring.cloud.client.ip-address}:${spring.application.instance_id:${server.port}}
prefer-ip-address: true

效果

效果图