【发布时间】:2021-10-08 03:12:58
【问题描述】:
我正在使用 Lombok,@Annotations 为我创建了 getter、setter 和构造函数。我有许多其他的类,杰克逊很容易反序列化。这是我试图反序列化的对象:
@Value
@Builder
public class RecipeListRemoveDTO {
int recipeListId;
}
在以下 Controller 方法中使用:
@DeleteMapping(path="/deleteRecipeListFromUser")
public @ResponseBody String deleteRecipeListFromUser(@RequestBody RecipeListRemoveDTO recipeListRemoveDTO) {
return recipeListService.removeRecipeListFromUser(recipeListRemoveDTO);
}
还有我要发送的 JSON:
{
"recipeListId": 2
}
但我收到错误消息:
"message": "JSON parse error: Cannot construct instance of com.prepchef.backend.models.dto.RecipeListRemoveDTO (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of com.prepchef.backend.models.dto.RecipeListRemoveDTO (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator) at [Source: (PushbackInputStream); line: 2, column: 5]"
有人知道为什么会这样吗?
【问题讨论】: