2
respostas

Esse e o erro que apareceu para mim

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2022-04-07 09:04:13.173 ERROR 13168 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'topicosController': Unsatisfied dependency expressed through field 'topicoRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'topicoRepository' defined in br.com.alura.forum.repository.TopicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class br.com.alura.forum.modelo.Topico at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:659 at at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:740 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:415 at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:303 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:1312 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6] SpringApplication.java:1301 at br.com.alura.forum.ForumApplication.main(ForumApplication.java:10) ~[classes/:na] ForumApplication.java:10 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Unknown Source) ~[na:na] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.6.6.jar:2.6.6] RestartLauncher.java:49 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'topicoRepository' defined in br.com.alura.forum.repository.TopicoRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class br.com.alura.forum.modelo.Topico at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1804

DefaultListableBeanFactory.java:1389 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.18.jar:5.3.18] DefaultListableBeanFactory.java:1309 at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656) ~[spring-beans-5.3.18.jar:5.3.18] AutowiredAnnotationBeanPostProcessor.java:656 ... 25 common frames omitted Caused by: java.lang.IllegalArgumentException: Not a managed type: class br.com.alura.forum.modelo.Topico at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final] MetamodelImpl.java:582 at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.6.7.Final.jar:5.6.7.Final] MetamodelImpl.java:85 at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.(JpaMetamodelEntityInformation.java:75) ~[spring-data-jpa-2.6.3.jar:2.6.3] JpaMetamodelEntityInformation.java:75 at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.6.3.jar:2.6.3] org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1863 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.18.jar:5.3.18] AbstractAutowireCapableBeanFactory.java:1800 ... 35 common frames omitted

2 respostas

O erro principal nessa saída é "Not a managed type: class br.com.alura.forum.modelo.Topico" - provavelmente está faltando o @Entity e demais anotações do JPA

Já adicionei essas anotações

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software