У меня есть запрос http, где я передаю объект в другой объект. Пример:
DisciplinaDTO{
private Long id_disciplina;
private String st_nome;
private ArrayList<AlunoListDTO> ls_alunos;
}
AlunoListDTO{
private Long id_aluno;
private String st_nome_aluno;
}
И когда я пытаюсь передать Json на этом объекте из моего интерфейса. Терминал покажет мне эту ошибку:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.tcc.secretaria.DTO.AlunoListDTO]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.tcc.secretaria.DTO.AlunoListDTO` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (PushbackInputStream); line: 1, column: 154] (through reference chain: com.tcc.secretaria.DTO.DisciplinaDTO["ls_alunos"]->java.util.ArrayList[0])] with root cause
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.tcc.secretaria.DTO.AlunoListDTO` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
Я думаю, это потому, что у меня есть Объект внутри другого объекта. Но как я могу это пройти?
Мой конструктор:
public DisciplinaDTO(Long id_disciplina, String st_nome, ArrayList<AlunoListDTO> ls_alunos) {
this.id_disciplina = id_disciplina;
this.st_nome = st_nome;
this.ls_alunos = ls_alunos;
}