I'm having trouble with my first steps using Spring-Boot with JPA. I've started with a pretty minimalistic example from Git using Gradle.
Now simply moving Customer
to another package, let's say to hello2
results in an exception Caused by: java.lang.IllegalArgumentException: Not an managed type: class hello2.Customer
. I tried to add
@ComponentScan(basePackageClasses= {Customer.class}) // AND OR
@EnableJpaRepositories(basePackageClasses= {Customer.class})
to Application
, but without success.
What am I doing wrong?
this is what worked for me :
Location of entities in Spring Boot can be configured using
@EntityScan
.By default,
@EnableAutoConfiguration
enables entity scanning in the package where it's placed (if it's not a default package).Giving same package location (i.e base package) for below annotation worked for me :-
You must locate entities and repositories pakages by using