Feign
Feign接口方式并没有成功,尝试了并没有成功
2020年10月16日再次尝试,成功,Success!
Feign的声明式的web service客户端,它让微服务之间调用更加简单,类似controller调用service,SpringCloud集成了Ribbon和Eureka,可在使用feign时提供负载均衡的http客户端
只要创建一个借口添加注解
Ribbon通过微服务名字访问
feign通过接口访问
版本问题
原因
版本问题,不同的版本导致使用的代码可能不同
重新选择springboot和springcloud的版本
这个版本中文网有翻译好的文档,到时找问题也方便
对应的是2.1.x的版本
所以最后选择2.1.17.release GA SpringBoot 和 Greenwich S6 版本的springcloud
创建项目时检查一下
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.17.RELEASE</version>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR6</spring-cloud.version>
</properties>
实现
角色和环境
-
-
provider服务端口、eureka 注册中心、consumer消费者
-
dashboard后续可以进行监控
-
provider和consumer都需要连接eureka