定义FeignService
import com.alibaba.fastjson.JSONObject;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "调用服务名")
public interface FeignService {
//请求方式根据被调用方定义 JSONObject 返回实体 可根据自己需要自定义实体接收 feign会自动转换属性名一致的字段
@PostMapping("/地址")
JSONObject xxxxx(@RequestBody 请求实体);
@GetMapping("/地址")
返回接收 xxxx(@RequestParam(value = "xxx") xxx);
}
impl层
//自动装配 直接调用拿到返回进行处理即可
@Autowired
private FeignService feignService;
feign 也可以支持服务间http调用
在feign注解中添加 url = "url"