文字描述
在EurekaServer的管控平台中,默认显示的服务实例名称是微服务定义的名称和端口;为了方便服务查看和定位,可以在服务提供者配置文件中,添加配置instance-id以便在EurekaServer管控平台中看到服务的ip:port
代码
spring:
application:
name: product_service
server:
port: 8761
eureka:
client:
serviceUrl: #eurekaserver的请求路径
defaultZone: http://localhost:8000/eureka/
instance:
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port} #作用:在EurekaServer管控台可以看到服务实例的ip:port
#spring.cloud.client.ip-address 获取ip地址