Meta-annotation, Composed-annotation

seringee·2023년 11월 28일
0

개발자개인공부

목록 보기
23/28

Meta-annotation

  • 어노테이션에 적용한 어노테이션
// component를 메타 어노테이션으로 적용한 service 어노테이션

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component // Meta Annotation
public @interface Service {
}
  • service 어노테이션이 부여된 클래스는 component 어노테이션이 직접 사용된 것처럼 컴포넌트 스캔의 대상이 됨

Composed-annotation

  • 하나 이상의 메타 어노테이션이 적용된 어노테이션
  • 합성 어노테이션이 적용되면 모든 메타 어노테이션이 적용된 것과 동일한 효과를 가짐
// controller, responsebody 메타 어노테이션이 적용된 restcontroller

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Controller // Meta Annotation
@ResponseBody // Meta Annotation
public @interface RestController {
}
profile
개발 공부 정리하고 저장하기

0개의 댓글