java - 如何在非持久实体中序列化嵌套的 PersistentEntityResource
问题描述
我希望PersistentEntityResource
在非持久实体中序列化嵌套。资源在没有嵌套的情况下返回时被序列化,因此该实体中可能没有问题。
这是我试图返回的实体的虚拟 + 包括持久实体在内的嵌套类
class ReturnedEntityDummy {
List<resourceWrapperDummy> dummy
ReturnedEntityDummy(List<resourceWrapperDummy> versions){
this.dummy = dummy
}
}
class resourceWrapperDummy<T> {
PersistentEntityResource content
Integer position
resourceWrapperDummy(PersistentEntityResource content, Integer position) {
this.content = content
this.position = position
}
}
最后一个类的PersistentEntityResource
内部是我想要序列化的类,这是我尝试返回时收到的错误消息ReturnedEntityDummy
:
Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: Failed to specialize base type org.springframework.data.mapping.PersistentEntity<java.lang.Object,org.springframework.data.mapping.PersistentProperty<java.lang.Object>> as org.springframework.data.jpa.mapping.JpaPersistentEntityImpl, problem: Type parameter #2/2 differs;
解决方案
推荐阅读
- ruby-on-rails - 从复选框插入多行
- php - 与父级嵌套的 json 数据
- r - 在 R 中使用 tidyverse 进行汇总后保留列
- jmeter - 如何在gitlab中读取jmeter结果
- google-bigquery - 从 gSheet 生成的 BigQuery 表无法通过 JDBC 驱动程序访问
- python - 替换 Pandas 列中的字符
- angular - 我们可以在Angular10的@Injectable服务中使用@viewChild吗
- javascript - 有条件地在 package.json 中安装不同版本的 npm 包
- c - C中字符和字符串函数的二维数组
- javascript - 使用 ngClass 函数将样式应用于字符串字符