springcloud ribbon实现负载均衡,页面报错:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Dec 23 16:02:26 CST 2020
There was an unexpected error (type=Internal Server Error, status=500).
Request URI does not contain a valid hostname: http://eureka_client_provider/find/1
解决方案:
使用ribbon实现负载均衡的时候;
如果指定springboot的版本比较低,比如是2.2.2.RELEASE,
则在.yml配置文件中配置的服务名称不能用下划线,换成中划线。
如果版本比较高,比如2.2.5.RELEASE,则下划线可用。
spring:
application:
name: eureka-client-provider
TbItem tbItem=restTemplate.getForObject("http://eureka-client-provider/find/1",TbItem.class);