Stereotypes

This is a method to classify a spring bean.

@Component

This is the highest-level stereotype. It tells spring that this is a spring bean, so during DI when spring scans and registers classes, create this bean. Once created, it is maintained by the Spring ApplicationContext.

Service / Controller / Repository

This is next (2nd) level of bean stereotyping. These are specialized forms of @ Component which allows you to provide more parameters during the annotation declaration. They get picked up during the component scan.

@Controller

This refers to a Spring MVC controller, typically responsible for preparing a model map with data and selecting a view name to be returned. It is usually used with the @RequestMapping annotation. The @RestController is a specialization of the @Controller annotation which represents @Controller and @ResponseBody together.

@Repository

Data controller for Domain Driven Design to encapsulate storage, retrieval and search. It provides error handling that is generic to the spring framework instead of providing errors at the implementation level.

@Service

An operation that is offered as an interface that stands alone in the model with no encapsulated state.