java - fastxml.jackson 在 Spring Boot 中解析错误的类
问题描述
我发现 fastxml.jackson 在我的项目中解析了错误的类。我有这个控制器方法:
@PutMapping
public Course updateCourse(@RequestBody CourseDto course) {
LoggedUser.logIn(authenticationFacade.getAuthentication().getName());
Course courseEntity = converter.convert(course);
return courseService.updateCourse(courseEntity);
}
但是当我向 API 发送 PUT 请求时,我得到了这个日志:
2018-12-16 13:36:58.339 WARN 9400 --- [nio-8080-exec-4] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unresolved forward references for: ; nested exception is com.fasterxml.jackson.databind.deser.UnresolvedForwardReference: Unresolved forward references for:
at [Source: (PushbackInputStream); line: 93, column: 1]Object id [3] (for `server.crm.entities.Course`) at [Source: (PushbackInputStream); line: 27, column: 24], Object id [3] (for `server.crm.entities.Course`) at [Source: (PushbackInputStream); line: 46, column: 24], Object id [3] (for `server.crm.entities.Course`) at [Source: (PushbackInputStream); line: 65, column: 24], Object id [3] (for `server.crm.entities.Course`) at [Source: (PushbackInputStream); line: 84, column: 24].]
您可以看到它尝试解析 server.crm.entities.Course 而不是 CourseDto,就像我在 @RequestBody 之后所做的那样。
你能帮我解决这个问题吗?
解决方案
推荐阅读
- cron - Airflow cron 表达式调度不正确
- c++ - 读取函数得到额外的字母 c++
- python - 通过函数调用时,Python exec 没有拾取范围
- google-sheets - Google 表格中独特的月份+年份组合
- sql - 我正在尝试使用具有多个 db abcdb、abcdb_index、abcdb_max、abcdb_log 的单个 bak 文件恢复 db
- java - 无法解析导入 org.openqa.selenium.webdriver
- spring - 触发后在 Spring Cloud Function 中重定向
- python - 使用树莓派在启动时播放 wav 文件
- php - 使用 php 上传 2MB 或更多文件时的问题
- html - 角度选项卡 - 不能将两个选项卡按钮居中和 50% witdh