java.lang.IllegalArgumentException: Not a managed type
![](/forum/man.png)
Asked on September 15, 2023
I am creating Spring Boot 3 application using CrudRepository.
I am getting error. How to resolve it.
Error:
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.myapp.entity.Article
at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:192) ~[hibernate-core-6.2.7.Final.jar:6.2.7.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:467) ~[hibernate-core-6.2.7.Final.jar:6.2.7.Final]
at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:97) ~[hibernate-core-6.2.7.Final.jar:6.2.7.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:82) ~[spring-data-jpa-3.1.3.jar:3.1.3]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.1.3.jar:3.1.3]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.1.3.jar:3.1.3]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.1.3.jar:3.1.3]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.1.3.jar:3.1.3]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.1.3.jar:3.1.3]
![](/forum/man.png)
Replied on September 15, 2023
Check for following points.
1. The entity class package should be subclass of main class package annotated with @SpringBootApplication.
2. Otherwise use @EntityScan with @SpringBootApplication annotation to specify entity class package.
@SpringBootApplication
@EntityScan("com.myapp.entity")
public class SpringAppStarter {
}
}
3. Annotate @EnableJpaRepositories with @SpringBootApplication because you are using CrudRepository.
![](/forum/man.png)
Replied on September 15, 2023
Thanks. Working.