Feign Client : Post 一个 Map<String,Object> in Request Body => feign.FeignException: status 400 reading MAp

Feign Client : Post a Map<String,Object> in Request Body => feign.FeignException: status 400 reading MAp

当我 Post Map<String,Object> 使用 Feign Client 时,我收到错误消息:

feign.FeignException: status 400 reading MAp .

代码

//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    Map<String, Object> save(@RequestBody Map<String,Object> map);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
    @RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    Map<String, Object> save(@RequestBody Map<String, Object> map) throws ParseException { }
}

你真的需要它成为地图吗?

尝试使用像

这样的 Hashset 或 HashMap
//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    HashMap<String, Object> save(@RequestBody HashMap<String,Object> map);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
    @RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    HashMap<String, Object> save(@RequestBody HashMap<String, Object> map) throws ParseException { }
}

//Client side
@Component
@FeignClient(name = ServiceID.TACHE)
@RibbonClient(name = ServiceID.TACHE)
public interface ITacheService extends ITache {
@RequestMapping(value = TACHE_CONTROLLER + "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    HashSet<String, Object> save(@RequestBody HashSet<String,Object> set);
}

@Controller
@RequestMapping("/task")
public class TaskController {

// Server side
    @RequestMapping(value = "/save", produces = {"application/json; charset=UTF-8"},method = RequestMethod.POST)
    @ResponseBody
    HashSet<String, Object> save(@RequestBody HashSet<String, Object> set) throws ParseException { }
}