boa tarde!
apos implantar o agendamento e o cancelamento de consulta ao rodar o projeto apresenta um erro no terminal, ja revisei o codigo e aparentemente esta correto
boa tarde!
apos implantar o agendamento e o cancelamento de consulta ao rodar o projeto apresenta um erro no terminal, ja revisei o codigo e aparentemente esta correto
Oi!
Manda o restante da stacktrace com a exception que está ocorrendo.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consultaController': Unsatisfied dependency expressed through field 'agenda': Error creating bean with name 'agendaDeConsultas': Unsatisfied dependency expressed through field 'medicoRepository': Error creating bean with name 'medicoRepository' defined in med.voll.api.domain.medico.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract med.voll.api.domain.medico.Medico med.voll.api.domain.medico.MedicoRepository.escolherMedicoAleatorioNaData(med.voll.api.domain.medico.Especialidade,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.voll.api.domain.medico.Medico med.voll.api.domain.medico.MedicoRepository.escolherMedicoAleatorioNaData(med.voll.api.domain.medico.Especialidade,java.time.LocalDateTime) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:788) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:768) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:146) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:509) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1445) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:600) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:523) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:346) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1155) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1121) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1056) ~[spring-beans-6.2.3.jar:6.2.3] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:987) ~[spring-context-6.2.3.jar:6.2.3] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627) ~[spring-context-6.2.3.jar:6.2.3] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.4.3.jar:3.4.3]
Database JDBC URL [Connecting through datasource 'HikariDataSource (HikariPool-1)'] Database driver: undefined/unknown Database version: 8.0.39 Autocommit mode: undefined/unknown Isolation level: undefined/unknown Minimum pool size: undefined/unknown Maximum pool size: undefined/unknown 2025-03-14T18:27:17.006-03:00 INFO 2185 --- [api] [ restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000489: No JTA platform available (set 'hibernate.transaction.jta.platform' to enable JTA platform integration) 2025-03-14T18:27:17.007-03:00 INFO 2185 --- [api] [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default' 2025-03-14T18:27:17.102-03:00 DEBUG 2185 --- [api] [ restartedMain] o.s.d.jpa.repository.query.NamedQuery : Looking up named query 'Usuario.findByLogin' 2025-03-14T18:27:17.103-03:00 DEBUG 2185 --- [api] [ restartedMain] o.s.d.jpa.repository.query.NamedQuery : Did not find named query Usuario.findByLogin 2025-03-14T18:27:17.165-03:00 INFO 2185 --- [api] [ restartedMain] r$InitializeUserDetailsManagerConfigurer : Global AuthenticationManager configured with UserDetailsService bean with name autenticacaoService 2025-03-14T18:27:17.184-03:00 DEBUG 2185 --- [api] [ restartedMain] o.s.d.jpa.repository.query.NamedQuery : Looking up named query 'Medico.findAllByAtivoTrue' 2025-03-14T18:27:17.185-03:00 DEBUG 2185 --- [api] [ restartedMain] o.s.d.jpa.repository.query.NamedQuery : Did not find named query Medico.findAllByAtivoTrue 2025-03-14T18:27:17.187-03:00 DEBUG 2185 --- [api] [ restartedMain] o.s.d.jpa.repository.query.NamedQuery : Did not find named query Medico.escolherMedicoAleatorioNaData.count 2025-03-14T18:27:17.193-03:00 INFO 2185 --- [api] [ restartedMain] o.s.d.j.r.query.QueryEnhancerFactory : Hibernate is in classpath; If applicable, HQL parser will be used. 2025-03-14T18:27:17.508-03:00 WARN 2185 --- [api] [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consultaController': Unsatisfied dependency expressed through field 'agenda': Error creating bean with name 'agendaDeConsultas': Unsatisfied dependency expressed through field 'medicoRepository': Error creating bean with name 'medicoRepository' defined in med.voll.api.domain.medico.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Could not create query for public abstract med.voll.api.domain.medico.Medico med.voll.api.domain.medico.MedicoRepository.escolherMedicoAleatorioNaData(med.voll.api.domain.medico.Especialidade,java.time.LocalDateTime); Reason: Validation failed for query for method public abstract med.voll.api.domain.medico.Medico med.voll.api.domain.medico.MedicoRepository.escolherMedicoAleatorioNaData(med.voll.api.domain.medico.Especialidade,java.time.LocalDateTime) 2025-03-14T18:27:17.509-03:00 INFO 2185 --- [api] [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default' 2025-03-14T18:27:17.510-03:00 INFO 2185 --- [api] [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2025-03-14T18:27:17.514-03:00 INFO 2185 --- [api] [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 2025-03-14T18:27:17.516-03:00 INFO 2185 --- [api] [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2025-03-14T18:27:17.522-03:00 INFO 2185 --- [api] [ restartedMain] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled. 2025-03-14T18:27:17.529-03:00 ERROR 2185 --- [api] [ restartedMain] o.s.boot.SpringApplication : Application run failed
Deu algum erro no seu repository. Manda aqui o codigo das suas classes: Medico, Consulta, MedicoRepository e ConsultaRepository
Na sua entidade Consulta a anotação @Entity
está assim:
@Entity(name = "consulta")
Ou seja, o nome da entidade está consulta (com a letra c em minúscula) e com isso as queries com JPQL precisam seguir esse mesmo padrão, mas na sua interface MedicoRepository tem uma query que está assim:
select c.medico.id from Consulta c
Na query está Consulta (com a letra C em maiúscula)
Faça esse ajuste e verifique a mesma coisa nas outras entidades (Medico e Paciente) e nas outras interfaces Repository.