@Repository not necessary when extending one of the predefined Repository interfaces

Cheav Sovannarith
Java Epic
Published in
1 min readSep 19, 2019

--

It is indeed not necessary to put the @Repository annotation on interfaces that extend JpaRepository; Spring recognizes the repositories by the fact that they extend one of the predefined Repository interfaces.

From the javadoc:

Annotation to enable JPA repositories. Will scan the package of the annotated configuration class for Spring Data repositories by default.

--

--