Stereotype Annotations

Learn about different annotations that can be used in place of the generic @Component annotation and their usage.

We'll cover the following...

Beans can be declared using the @Component annotation and the <bean> tag. But there are other ways to define beans. We will look at some of them in this lesson.

Beans can be declared using the @Bean annotation in a configuration class or by using the @Controller, @Service, and @Repository annotations. These annotations are used at different layers of an enterprise application. A typical application has the following layers:

Press + to interact
Application layering pictorial representation
Application layering pictorial representation

The web or UI layer interacts with the client program, the service layer provides an abstraction between the web and data access layer as well as taking care of the business logic, and the data layer interacts with a database or an external interface. @Component is a generic annotation. It can be used in any layer, if the developer is unsure about where the bean belongs. The other three annotations, @Controller, @Service, and @Repository, are specific to layers.

Press + to interact
Stereotype annotations
Stereotype annotations

@Controller

...