1.顯示IP
效果預覽:
配置yml:
eureka: client: service-url: defaultZone: http://localhost:9000/eureka/,http://localhost:8000/eureka/ #多個eurekaserver之間通過","分割 instance: prefer-ip-address: true #使用IP地址注冊 instance-id: ${spring.cloud.client.ip-address}:${server.port} #向注冊中心注冊我們的IP和端口
2.設置心跳間隔和服務續約時間
eureka: client: service-url: defaultZone: http://localhost:9000/eureka/,http://localhost:8000/eureka/ #多個eurekaserver之間通過","分割 instance: prefer-ip-address: true #使用IP地址注冊 instance-id: ${spring.cloud.client.ip-address}:${server.port} #向注冊中心注冊我們的IP和端口 lease-renewal-interval-in-seconds: 5 #設置向注冊中心發送心跳的時間,默認是30秒 lease-expiration-duration-in-seconds: 10 #設置預約到期時間默認是90秒
停止服務之后,10秒之后注冊中心會把該服務移除