Issue
I'm using Spring Data JPA repositories (like MyRepo extends JpaRepository
) and it works without @Repository
and without @EnableJpaRepositories
annotations. Could someone explain why?
Solution
Probably you are using Spring Boot.
Spring Data repositories usually extend from the Repository or CrudRepository interfaces. If you use auto-configuration, repositories are searched from the package containing your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) down.
Please check the Spring Boot Reference Documentation (v2.7.2) for more details.
Answered By - Mykhailo Hodovaniuk
Answer Checked By - Robin (JavaFixing Admin)