9-9 Feign整合Ribbon




Ribbon整合

先把configuration注掉

把原来注释的方法恢复注释,invokerProviderController方法

我们原来是通过url的形式访问的

把URL也注掉,这样就变成了一个没有访问目标的

重启consumer服务,肯定是无法访问的

http://localhost:7201/sayhello/feign?message=111

ERROR (DirectJDKLog.java:175)- Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.RuntimeException: com.netflix.client.ClientException: Load balancer does not have available server for client: providerTest] with root cause
com.netflix.client.ClientException: Load balancer does not have available server for client: providerTest

改成eureka里面注册的服务名

重启服务测试

http://localhost:7201/sayhello/feign?message=111

演示负载均衡

复制Provider的





和我们的配置文件对应起来

这里也改成pro-02 然后点击Apply


选择并启动



等服务注册到eureka。 可能会稍微的等一会。



这里之前配置的是轮询的方式

结束

原文地址:https://www.cnblogs.com/wangjunwei/p/12846443.html