如何使用feign调用服务
2020-02-12 16:04
465 查看
第一步添加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency>
第二步:启动类上新增注解
@EnableFeignClients
第三步:新增ProductClient接口内容如下:
//设置访问服务名product @FeignClient(name = "product") public interface ProductClient { @GetMapping("/msg") //表示访问的服务下的接口名msg String productMsg(); }
第四步:调用服务
@Autowired private ProductClient productClient; @GetMapping("getProductMsg") public String getProductMsg() { String response = productClient.productMsg(); log.info("response={}",response); return response; }
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Spring boot2X Consul如何使用Feign实现服务调用
- 如何解决使用Feign远程调用服务时返回Null的情况
- ArcGIS API for javascript开发笔记(六)——REST详解及如何使用REST API调用GP服务
- 如何使用来自 ASP.NET 的客户端证书调用 Web 服务
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- 微服务笔记之Spring Cloud 中使用Feign调用接口服务(Finchley)
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- SpringCloud Cloud查找调用REST服务使用RestTemplate(ribbon负载) 或feign模式火推13
- springcloud使用feign实现服务间条用,参数数据太大,无法调用成功解决方法
- 微服务中如何使用RestTemplate优雅调用API(拦截器、异常处理、消息转换)
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- SpringCloud使用Feign进行服务调用
- Spring Boot 中使用Feign作为HTTP客户端调用远程HTTP服务
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- Spring Cloud(十二)声名式服务调用:Feign 的使用(下)
- 使用Spring Cloud Feign作为HTTP客户端调用远程HTTP服务
- Spring-cloud-eureka使用feign调用服务接口
- 使用eclipse一步一步创建SpringCloud项目(二)—— 使用feign和ribbon调用微服务
- 如何使用PHP调用API接口( 如何POST一个JSON格式的数据给Restful服务)
- 如何使用Spring Cloud – 简单服务流程(服务发现与API调用)