Where should @Service annotation be kept? Interface or Implementation?
I'm developing application using Spring. I'm required to use @Service annotation. I've ServiceI and ServiceImpl such that ServiceImpl implements ServiceI. I'm confused here that where should I keep the @Service annotation.
Should I annotate interface or implementation with @Service annotation? What are the differences between these two approaches?
auto-detection when using annotation-based configuration and classpath scanning.
From my experience I am always using @Service annotation on the interfaces or abstract classes and annotations like @Component and @Repository for their implementation. @Component annotation I am using on those classes which serves basic purposes, simple Spring beans, nothing more. @Repository annotation I am using in the DAO layer, for e.g. if I have to communicate to the database, have some transactions, etc.
So I would suggest to annotate your interface with the @Service and other layers depending on the functionality.