基于user1685095的答案,您可以创建自定义控制器并公开帖子,因为它似乎尚未由PersonRestController
collection of Person
Spring-date-rest
@RepositoryRestController
@RequestMapping(value = "/persons")
public class PersonRestController {
private final PersonRepository repo;
@Autowired
public AppointmentRestController(PersonRepository repo) {
this.repo = repo;
}
@RequestMapping(method = RequestMethod.POST, value = "/batch", consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseEntity<?> savePersonList(@RequestBody Resource<PersonWrapper<Person>> personWrapper,
PersistentEntityResourceAssembler assembler) {
Resources<Person> resources = new Resources<Person>(repo.save(personWrapper.getContent()));
//TODO add extra links `assembler`
return ResponseEntity.ok(resources);
}
}
要修复的人员包装器:
无法反序列化 org.springframework.hateoas.Resources 的实例,START_ARRAY个 token\n 位于 [来源:java.io.PushbackInputStream@3298b722;行:1,列:1]
更新
public class PersonWrapper{
private List<Person> content;
public List<Person> getContent(){
return content;
}
public void setContent(List<Person> content){
this.content = content;
}
}
public class Person{
private String name;
private String email;
// Other fields
// GETTER & SETTER
}