7-5 Ribbon整合Eureka
启动我们的consumer服务。

这个有个sayHello的方法

刷新页面,默认的就已经是负载均衡了。
http://localhost:7201/sayhello?message=eureka



简化开发的流程
让restTemplate 具有负载均衡的能力。加上@Loadbalanced注解

restTemplate默认会把字符串hello-service-provider替换成你的服务host+port的形式。

uri还是原来的,正常调用

重启consumer服务




还是轮询的操作,但是代码简化了很多。

到目前为止 serverList基本就完成了。下面就是要玩负载均衡算法了。

浙公网安备 33010602011771号