Ao utilizar o http://localhost:8080/medicos
Está apresentando erro no terminal Aplicação continua rodando.
'' 6-26T21:30:12.339-03:00 INFO 6280 --- [api] [ restartedMain] med.voll.api.ApiApplication : Started ApiApplication in 19.031 seconds (process running for 20.363) 2024-06-26T21:30:45.377-03:00 INFO 6280 --- [api] [nio-8080-exec-2] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet' 2024-06-26T21:30:45.378-03:00 INFO 6280 --- [api] [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet' 2024-06-26T21:30:45.380-03:00 INFO 6280 --- [api] [nio-8080-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms 2024-06-26T21:31:00.026-03:00 WARN 6280 --- [api] [nio-8080-exec-4] PageModule$PlainPageSerializationWarning : Serializing PageImpl instances as-is is not supported, meaning that there is no guarantee about the stability of the resulting JSON structure! For a stable JSON structure, please use Spring Data's PagedModel (globally via @EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO)) or Spring HATEOAS and Spring Data's PagedResourcesAssembler as documented in https://docs.spring.io/spring-data/commons/reference/repositories/core-extensions.html#core.web.pageables.''
@GetMapping
public Page<DadosListagemMedico> listar(@PageableDefault(size = 10, sort = {"id"}) Pageable paginacao){
return repository.findAll(paginacao).map(DadosListagemMedico::new);
}
public record DadosListagemMedico(
Long id,
String nome,
String email,
String crm,
Especialidade especialidade){
public DadosListagemMedico (Medico medico){
this( medico.getId(), medico.getNome(), medico.getEmail(), medico.getCrm(),medico.getEspecialidade() );
}
public Medico(DadosCadastroMedicosDTO dados) {
this.nome = dados.nome();
this.email = dados.email();
this.crm = dados.crm();
this.especialidade = dados.especialidade();
this.endereco = new Endereco(dados.endereco());
this.telefone = dados.telefone();
}