如果是Json请求要加加上 @Headers(“Content-Type: application/json”)
(@Param(“id”) 注意加上
@RequestLine("GET /call/{id}")
public Police getPerson(@Param("id")Integer id);
@RequestLine("POST /create")
@Headers("Content-Type: application/json")
public String createPeople(Police police);
json 请求 要编码encoder 把对象转成json格式
TestFeign testFeign = Feign.builder().encoder(new GsonEncoder()).target(TestFeign.class,
"http://localhost:8081");
返回时json转换成对象要解码decoder
TestFeign testFeign = Feign.builder().decoder(new GsonDecoder()).target(TestFeign.class,"http://localhost:8081");
返回方法
@RequestMapping(value = "/create", method = RequestMethod.POST)
public Police call( @RequestBody Police police) {
System.out.println(police.toString());
return police;
}