一 模块间调用Feign

二 代码
https://github.com/XUEZHIQIAN/SpringCloud-Feign.git
package com.hang.cloud.service;
import com.hang.cloud.service.fallback.OrderServiceFallback;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* api
*
* @author Hang W
*/
@FeignClient(name = "order-service", fallback = OrderServiceFallback.class)
public interface OrderService {
@GetMapping("order/{id}")
String queryOrderById(@PathVariable(value="id") Long id);
}
三 说明
1.使用 Eureka 服务注册中心
2.使用 Feign 进行调用
本文介绍如何在Spring Cloud项目中使用Feign实现模块间的API调用,通过示例代码展示FeignClient注解及GetMapping的使用,适用于Eureka服务注册中心的环境下。
525

被折叠的 条评论
为什么被折叠?



