我使用Spring-sync作为RFC 6902 (JSON Patch)
. 客户端向我发送一个JsonNode
表示要应用于服务器对象的操作。
我的代码如下:
@PatchMapping(path = "/profile/{userId}")
public ResponseEntity<Void> patchUserProfile(@PathVariable Integer userId, @RequestBody JsonNode patchJsonNode) {
JsonPatchMaker jsonPatchMaker = new JsonPatchMaker();
Patch patch = jsonPatchMaker.fromJsonNode(patchJsonNode);
UserProfileDto originalUserProfileDto = ...
UserProfileDto patchedUser = patch.apply(originalUserProfileDto, UserProfileDto.class);
userService.save(patchedUser);
return ResponseEntity.status(HttpStatus.OK).body(null);
}
我有一个意想不到的 JavaClassCastException
告诉我该对象不能转换为相同的类型!!?? 这怎么可能?
在堆栈跟踪下方:
java.lang.ClassCastException: com.roufid.api.dto.user.UserProfileDto cannot be cast to com.roufid.api.dto.user.UserProfileDto
注意:我的类是由相同的加载的classloader
,它是Serializable
.
我在用着 :
- 弹簧同步:1.0.0.M1