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;
共 (0) 个答案