- feign中有一个controller对应的的调用方法:
- @RequestMapping(“hi01/{orderId}”)
@ResponseBody
public String hello1(@PathVariable String orderId) throws Exception {
String hello = orderService.hello01(orderId);
return hello;
} - 注入的接口方法:hello01
- @FeignClient(“order-service”)
public interface OrderService {
@RequestMapping(value=”order/query/{orderId}”,method=RequestMethod.GET)
public String hello01(@RequestParam(“orderId”) String orderId);
} - [email protected]收对应的参数
- @RequestMapping(value=”order/query/{orderId}”,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Order queryOrderById(
@PathVariable String orderId) {
。。。。
return order;
} - produces = MediaType.APPLICATION_JSON_VALUE
- 在支持的jar下,该属性默认控制返回到feign的数据格式为json或者xml
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/16279.html