Very often I see code like the following:
@Repository
public interface CustomerRepository extends JpaRepository<Customer, Long>
And my question is why do we need this @Repository annotation?
I understand why @Repository exist, and why we may need to put in on top of some class.
But classes didn't inherit annotations from interfaces in Java. Of course, I can miss something about Spring 'magic', but the default JPA implementation class is the following:
@Repository
@Transactional(readOnly = true)
public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T, ID>
and it contains @Repository on its own, so why we need it on our interface?
Spring Data documentation also didn't say anything about @Repository in the related section, but some occasional examples from the other parts of documentation contain code fragment where @Repository is present, so maybe something was changed over time?