Can @Component, @Repository and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device?>
Difference between @Component, @Repository, @Controller & @Service annotations
@Component – generic and can be used across application.
@Service – annotate classes at service layer level.
@Controller – annotate classes at presentation layers level, mainly used in Spring MVC.
@Repository – annotate classes at persistence layer, which will act as database repository.
@Controller
= @Component ( Internal Annotation ) + Presentation layer Features
@Service
= @Component ( Internal Annotation ) + Service layer Features
@Component
= Actual Components ( Beans )
@Repository
= @Component ( Internal Annotation ) + Data Layer Features ( use for handling the Domain Beans )