Spring Cloud全解析:服务调用之OpenFeign简介
OpenFeign简介
OpenFeign是SpringCloud对于Feign进行的再次封装,使其支持了SpringMVC的标准注解以及HttpMessageConverters
依赖
<!-- openFeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
配置启动类
@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients // 开启feign
public class ConsumerApp {
public static void main(String[] args) {
SpringApplication.run(ConsumerApp.class,args);
}
}
feign接口编写
@FeignClient(value = "SPRINGCLOUD2-PROVIDER")
public interface DeptClient {
@GetMapping(value = "/dept/get/{id}")
CommonResult<Dept> get(@PathVariable("id") long id);
}
直接调用该方法就可以调用该微服务的接口
参考文献
原文地址:https://blog.csdn.net/Lxn2zh/article/details/142516276
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!