Ribbon引用
首先我按照书上的来如下图。
书太久远了,和现在的Springboot版本已经不适用了,项目都跑不起来,然后我想着eureka也是,要加一个netflix,会不会有这个原因呢。
然后我就去找了下图的jar包。
这个能跑是能跑,但是消费的时候显示如下图。
这不尽扯淡呢,我明明配置好了
@RestController
public class ConsumerController {
@Autowired
RestTemplate restTemplate;
@RequestMapping(value = "/ribbon-consumer",method = RequestMethod.GET)
public String index(){
return restTemplate.getForEntity("http://HELLO-SERVICE/hello",String.class).getBody();
}
}
然后又查询了一下,说是eureka-client已经整合ribbon了,然后我将ribbon的依赖删除,果然能跑了。
的确是负载均衡了嗷,就是加载有点慢
@EnableDiscoveryClient和@EnableEurekaClient区别
下面这篇博客写得蛮明白了。
https://blog.csdn.net/u012734441/article/details/78256256?locationNum=1&fps=1