Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

[Dúvida] Erro - org.springframework.beans.factory.UnsatisfiedDependencyException

Eu estou com o erro org.springframework.beans.factory.UnsatisfiedDependencyException depois de ter adicionado o método para escolha aleatória e criar a Query no repository do médico...

4 respostas

Oi!

Manda a stacktrace aqui para identificação da causa raiz do problema.

1. - org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consultController': Unsatisfied dependency expressed through field 'scheduleConsult': Error creating bean with name 'scheduleConsult': Unsatisfied dependency expressed through field 'doctorRepository': Error creating bean with name 'doctorRepository' defined in med.projectvoll.apiproject.domain.doctor.DoctorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime)

2 - Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleConsult': Unsatisfied dependency expressed through field 'doctorRepository': Error creating bean with name 'doctorRepository' defined in med.projectvoll.apiproject.domain.doctor.DoctorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime)

3 - Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'doctorRepository' defined in med.projectvoll.apiproject.domain.doctor.DoctorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime)

4 - Caused by: org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime)

5 - Caused by: java.lang.IllegalArgumentException: Validation failed for query for method public abstract med.projectvoll.apiproject.domain.doctor.Doctor med.projectvoll.apiproject.domain.doctor.DoctorRepository.chooseDoctorFreeInDate(med.projectvoll.apiproject.domain.doctor.Specialty,java.time.LocalDateTime)

6 - Caused by: java.lang.IllegalArgumentException: org.hibernate.query.sqm.UnknownEntityException: Could not resolve root entity 'Consult'

7 - Caused by: org.hibernate.query.sqm.UnknownEntityException: Could not resolve root entity 'Consult'

solução!

O problema está na sua query, na interface DoctorRepository. A exception diz que não encontrou a entidade de nome Consult.

Verifica na entidade Consult a anotação @Entity qual o nome correto, pois esse deve ser o nome utilizado nas consultas JPQL

Perfeito Professor! Tive que fazer a mesma coisa com a classe Doctor, uma coisa tão simples! Nossa! Obrigado!