调试的时候发现有类似如下报错:

JSON parse error: Cannot construct instance of `xxx` (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 `xxx` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: (PushbackInputStream); line: 1, column: 2]

controller参数传了一个实体类:CategoryEntity

	@RequestMapping("/save")
    public R save(@RequestBody CategoryEntity category){
		categoryService.save(category);

        return R.ok();
    }

原本该实体是:

@Data
@TableName("pms_category")
public class CategoryEntity implements Serializable {
	...
}

在该实体类上加上@NoArgsConstructor(无参构造),就可以了:

@Data
@NoArgsConstructor
@TableName("pms_category")
public class CategoryEntity implements Serializable {
	...
}
Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐