思维导图
文章已收录Github精选,欢迎Star:https://github.com/yehongzhi/learningSummary
前言
目前在SpringCloud技术栈中,调用服务用得最多的就是OpenFeign,所以这篇文章讲一下OpenFeign,希望对大家有所帮助。
一、构建工程
使用Nacos作为注册中心,不会搭建Nacos的话,可以参考上一篇注册中心的文章。
首先父工程parent引入依赖。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Finchley.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>0.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign</artifactId>
<version>2.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency