They are almost the same - all of them mean that the class is a Spring bean. @Service
, @Repository
and @Controller
are specialized @Component
s. You can choose to perform specific actions with them. For example:
@Controller
beans are used by spring-mvc@Repository
beans are eligible for persistence exception translationAnother thing is that you designate the components semantically to different layers.
One thing that @Component
offers is that you can annotate other annotations with it, and then use them the same way as @Service
.
For example recently I made:
@Component
@Scope("prototype")
public @interface ScheduledJob {..}
So all classes annotated with @ScheduledJob
are spring beans and in addition to that are registered as quartz jobs. You just have to provide code that handles the specific annotation.