本人最近在spring boot中集成了eureka,遇到了下面几个坑,并记录解决办法:
eureka:
instance:
hostname: localhost
# 使用IP注册
preferIpAddress: true
加入preferIpAddress配置即可
eureka:
instance:
hostname: localhost
# 使用IP注册
preferIpAddress: true
metadata-map:
contextPath: ${server.context-path:}
ServiceInstance serviceInstance=loadBalancerClient.choose("EBPM");
sb.append( "http://"+serviceInstance.getHost()+":"+serviceInstance.getPort()+ serviceInstance.getMetadata().get("contextPath") );