微服务调用时报错

在公司做微服务时,由于有的微服务用的是别人的模块,所以自己的模块在注册中心显示的其实是当前模块所在电脑的主机名,以至于在调用其他不同电脑的微服务时报错:

feign.RetryableException: Connection refused: connect executing POST http://service-log/sysLogInfoApi/findSysLogInfoByPage

 

解决方法:

在配置文件中添加:

server.port=<设置模块的端口>

#设置允许跨域
eureka.instance.prefer-ip-address=true
#这样写eureka服务注册中心会显示本机ip+端口号
eureka.instance.instance-id= ${spring.cloud.client.ipAddress}:${server.port}

原文地址:https://www.cnblogs.com/xdzy/p/10853971.html