java - Jackson 错误解析器尝试解析子类型,但我的类是简单的 POJO
问题描述
味精错误:
{
"@class": "java.util.LinkedHashMap",
"timestamp": [
"java.util.Date",
"2018-10-04T17:12:35.742+0000"
],
"status": 400,
"error": "Bad Request",
"message": "JSON parse error: Missing type id when trying to resolve subtype of [simple type, class br.com.adtsys.ciee.auth.user.data.request.LoginRequest]: missing type id property '@class'; nested exception is com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Missing type id when trying to resolve subtype of [simple type, class br.com.adtsys.ciee.auth.user.data.request.LoginRequest]: missing type id property '@class'\n at [Source: (PushbackInputStream); line: 4, column: 1]",
"path": "/auth/login"
}
但我的课是一个简单的 POJO
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class LoginRequest implements Serializable {
private String username;
private String password;
}
该对象是我的控制器中的一个参数,我在其中对 POST 方法进行请求,并且该对象使用 @Body 注释进行注释,当我调用其余端点时,spring 尝试在我的对象中转换我的 JSON,但发生了该错误。我正在使用嵌入在 Spring Boot 版本 2.0.5 中的 jackson 库,在我将 spring-boot 版本 1.5.3 升级到 2.0.5 后开始发生该错误。我已经搜索过这个问题,但不幸的是直到现在什么都没有。有人知道这个问题。
解决方案
推荐阅读
- javascript - 如何使用 python 将数据记录到仪表板应用程序
- javascript - 即使在 XMLHttpRequest (JavaScript/ReactJS) 上切片后上传大文件时浏览器崩溃
- centos - Bareos - 无法连接到 Director。放弃
- ios - 如何在没有 App Store (OTA) 的情况下分发 IOS App?
- python - 在 Docker、pynetdicom 和烧瓶中以单个 Python 脚本运行 2 个服务器
- ruby-on-rails - 如何在 Ruby on Rails 中将文本方法添加到日期集合选择?
- javascript - ExtJS - 如何使用 PWA 构建开发应用程序?
- javascript - 如何使用 jQuery UI 对话框更新元素的内容?
- jestjs - 如何在 Jest 中测试直系子女数?
- r - 如何在 R 中包含使用聚合()聚合的行数