DEV Community


Posted on • Updated on

Stereotype and Meta Annotations in Spring

@ComponentScan checks not only for components but for annotations that are themselves annotated with @Component too. Those are stereotype annotations:

  • Component
  • Controller
  • Repository
  • Service

We could add @Configuration and @RestController because @Configuration is annotated with @Component and @RestController is annotated with @Controller (some people disagree)

Meta-annotations are annotations that can be used to annotate other annotations. For example, the next custom annotation @MyTransactionalService is a meta-annotation:

public class TransferServiceImpl implements TransferService {

public @interface MyTransactionalService {
  String value() default "";
Enter fullscreen mode Exit fullscreen mode

Top comments (0)