服务启动后,如果没有配置instance-id,则再Eureka上面注册的 instanceId 是这样的
在Spring Cloud中,服务的Instance ID的默认值是${spring.cloud.client.hostname}:${spring.application.name}:${spring.application.instance_id:${server.port}}
,也就是机器主机名:应用名称:应用端口
那怎么自定义Eureka的Instance ID?
在Eureka client添加配置:
eureka: instance: prefer-ip-address: true instance-id: ${spring.cloud.client.ipAddress}:${server.port}
重启服务也还是不对,后来发现是SpringCloud 2.0 已经改成 ${spring.cloud.client.ip-address} 了
相应改掉就可以啦: