SpringBoot方法Body参数过多

SpringBoot Method has too many Body parameters

我创建了假客户端来调用我的 RestApi。当我尝试 运行 我的服务时,我收到来自此 requestMethod 的错误 Method has too many Body parameters 对于 @RequestBody 我只使用了对象类型,因为每次我都可以发送另一个正文请求。

@RequestMapping(path = "/v1/products/{product}/companies/{companyId}", method = RequestMethod.POST,
            consumes = "application/json", produces = "application/json")
    ResponseEntity<Object> createProduct(URI baseUri,
                                         @HeaderParam("tenant-id") String tenantId,
                                         @PathVariable("product") String product,
                                         @PathVariable("companyId") String companyId,
                                         @RequestBody Object reqBody);

您不能使用 Object 作为类型,请尝试使用我们的 Class.The 框架指定无法知道使用哪个实体作为响应。

@RequestMapping(path = "/v1/products/{product}/companies/{companyId}", method = RequestMethod.POST,
            consumes = "application/json", produces = "application/json")
    ResponseEntity<MyEntity> createProduct(URI baseUri,
                                         @HeaderParam("tenant-id") String tenantId,
                                         @PathVariable("product") String product,
                                         @PathVariable("companyId") String companyId,
                                         @RequestBody Object reqBody);