【发布时间】:2016-02-08 18:17:10
【问题描述】:
我有一个@ManyToMany 和一个@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)。
如果我将对象发回,我会得到:
error: "Bad Request"
exception: "org.springframework.http.converter.HttpMessageNotReadableException"
message: "Could not read document: No _valueDeserializer assigned↵ at [Source: java.io.PushbackInputStream@3021b8dc; line: 1, column: 244] (through reference chain: at.scool.model.db.Teacher["classes"]->java.util.HashSet[0]->at.scool.model.db.SchoolClass["teachers"]->java.util.HashSet[0]->at.scool.model.db.Teacher["id"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No _valueDeserializer assigned↵ at [Source: java.io.PushbackInputStream@3021b8dc; line: 1, column: 244] (through reference chain: at.scool.model.db.Teacher["classes"]->java.util.HashSet[0]->at.scool.model.db.SchoolClass["teachers"]->java.util.HashSet[0]->at.scool.model.db.Teacher["id"])"
path: "/api/teacher/1"
status: 400
timestamp: 1446921619542
源代码
Spring boot with JPA and ManyToMany: JsonIdentifyInfo not working properly
老师
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
private Set<SchoolClass> classes = new HashSet<>();
学校班级
@ManyToMany
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
private Set<Teacher> teachers = new HashSet<>();
【问题讨论】:
-
你确定你的语法正确吗??
-
用我的代码更新帖子
-
@rala 你得到解决方案了吗?
标签: java spring rest spring-boot