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

Mudando o projeto de lugar

Bom dia!

Tentei recortar e colar o projeto em outro lugar, em um repositório git que estão todos os cursos da Alura, porém ocorreu o erro abaixo. Podem me ajudar? Não tenho ideia do que fazer, estou usando o Intellij IDEA

=========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.0.7)

2023-06-01T11:05:57.097-03:00  INFO 12920 --- [  restartedMain] med.voll.api.ApiApplication              : Starting ApiApplication using Java 17.0.7 with PID 12920 (C:\Users\leona\Documents\GitHub\Oracle-Next-Education\Curso11 Spring Boot 3 desenvolva uma API Rest em Java\api\target\classes started by leona in C:\Users\leona\Documents\GitHub\Oracle-Next-Education\Curso11 Spring Boot 3 desenvolva uma API Rest em Java\api)
2023-06-01T11:05:57.113-03:00  INFO 12920 --- [  restartedMain] med.voll.api.ApiApplication              : No active profile set, falling back to 1 default profile: "default"
2023-06-01T11:05:57.333-03:00  INFO 12920 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-06-01T11:05:57.334-03:00  INFO 12920 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-06-01T11:05:59.631-03:00  INFO 12920 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-06-01T11:05:59.903-03:00  WARN 12920 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'medicoRepository' defined in med.voll.api.repositories.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot register bean definition [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null; defined in med.voll.api.repositories.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration] for bean 'medicoRepository' since there is already [Root bean: class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodNames=null; destroyMethodNames=null; defined in med.voll.api.medico.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration] bound.
2023-06-01T11:05:59.931-03:00  INFO 12920 --- [  restartedMain] .s.b.a.l.ConditionEvaluationReportLogger : 

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-06-01T11:05:59.999-03:00 ERROR 12920 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'medicoRepository', defined in med.voll.api.repositories.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration, could not be registered. A bean with that name has already been defined in med.voll.api.medico.MedicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true


Process finished with exit code 0
2 respostas
solução!

Oi Leonardo!

Confere as mudanças que você fez, pois o erro indica que seu projeto está com duas interfaces repositories com o mesmo nome, mas em pacotes distintos:

  1. med.voll.api.repositories.MedicoRepository
  2. med.voll.api.medico.MedicoRepository

Fala Prof. Rodrigo,

Realmente eu devo ter alterado algo de lugar que nem sei oq foi. Já tinha puxado o ultimo commit e fiz tudo de novo, e agora deu certo.

Obrigado pelo retorno!!