Home Java의 Annotation 알아보기 - @Component
Post
Cancel

Java의 Annotation 알아보기 - @Component

출처: Package org.springframework.core.annotation / Annotation Interface AliasFor


@Component

1
2
3
4
5
6
7
8
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
public @interface Component {

	String value() default "";
}
Indicates that an annotated class is a "component". Such classes are considered as candidates for auto-detection when using annotation-based configuration and classpath scanning. Other class-level annotations may be considered as identifying a component as well, typically a special kind of component: e.g. the @Repository annotation or AspectJ's @Aspect annotation.

@Component 애너테이션이 붙은 클래스를
“컴포넌트”임을 알려주고, 즉, 해당 클래스는
애너테이션 기반 설정과 클래스패스classpath 스캔 시에
자동 감지되는 대상이 된다.
클래스에 붙은 다른 애너테이션들 역시도
컴포넌트로 인식된다.
특히 컴포넌트의 특별한 경우로,
@Repository
AspectJ의 Aspect 애너테이션 등이 있다.


선택적 요소 - 요약

Optional Element Summary

  • 제어자Modifier, 타입Type
    : String
  • 선택적 요소Optinal element
    : value
  • 설명
    : 해당 값value
    컴포넌트 이름에 대한 암시를 나타내는데,
    이 값은 컴포넌트가 자동 감지되는 경우에
    스프링 bean으로 변환된다.


요소에 대한 설명

Element Details

value
String    value

해당 값value
컴포넌트 이름에 대한 암시를 나타내는데,
이 값은 컴포넌트가 자동 감지되는 경우에
스프링 bean으로 변환된다.

  • 반환 값
    암시로 나타내어진 컴포넌트 이름
    (없을 시에는 empty String 값)
Contents