首先来简单模式一个通过RequestMapping 请求,PostMapping 接收请求,使用过程中可能会碰到的一些问题,请见如下:
一:通过RequestMapping 客户端请求
@Service @FeignClient(value = "test",fallback = Test.class) public interface TestFgign { /** * 定义一个FeignClient 客户端请求 * 1.method 请求方式需要服务端保持一致 客户端是POST 服务端一定需要是POST * 2.produces 数据格式需要与服务端保持一致 **/ @RequestMapping(value = "/test/testFeign", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") Demo testFeign(@RequestBody Person person); }二:通过PostMapping 接收
@RestController public class AppController { @PostMapping(value = "/testFeign", produces = "application/json;charset=UTF-8") public Demo testFeign(@RequestBody Person person) { return null; } }
1.method 请求方式需要服务端保持一致 客户端是POST 服务端一定需要是POST
2.produces 数据格式需要与服务端保持一致
3.@RequestBody 参数只能存在一个,业务功能中可能会存在的一些要求
1.对象, String 类型 (@RequestBody Person person, @RequestParam String id)