Springboot集成Ribbon使用RestTemplate时:java.lang.IllegalStateException: No instances available for localhost

目录
分析
在启动类中配置使用了 @LoadBalanced
再调用
|
|
必须使用应用名作为代替ip:端口,
http://127.0.0.1:8080/hello
改成
http://应用名/hello
不然会报错
使用RestTemplate时报错
|
|
1:不要使用ip+port的方式访问,取而代之的是应用名
2:这种方式发送的请求都会被ribbon拦截,ribbon从eureka注册中心获取服务列表,然后采用均衡策略进行访问