
Stereotype Annotation이란?Annotations denoting the roles of types or methods in the overall architecture (at a conceptual, rather than implementation, level).
: 전체 아키텍처(구현 수준이 아닌 개념적 수준)에서 타입 또는 메서드의 역할을 나타내는 어노테이션
Sterotype의 클래스들을 탐지하고 Bean으로 등록한다.즉, Stereotype Annotation을 이용하면 자동으로 빈을 등록할 수 있다!
Stereotype Annotation 종류
@Component이 어노테이션이 붙은 클래스가 "스프링 컴포넌트"임을 나타낸다.
@Component가 붙은 클래스는 빈 스캐너를 통해 자동으로 빈으로 등록된다.@Controller, @Service, @Repository의 최상위 어노테이션@Component vs @Bean모두 스프링 빈을 만드는데 사용된다!
@Component는 @ComponentScan을 사용해서 자동으로 찾아주고 관리해준다.@Bean은 @Configuration으로 선언된 클래스 내에 있는 메서드를 정의할 때 사용한다. Bean이 되며, default로 메서드 이름이 Bean의 이름이 된다.@Repository이 어노테이션이 붙은 클래스가 "리포지토리"임을 나타낸다.
@Repository 어노테이션을 제공한다.@Component를 부여해도 되지만, 스프링에서는 @Repository 어노테이션을 권장한다.@Service이 어노테이션이 붙은 클래스가 "서비스"임을 나타낸다.
@Component와 같이 빈을 생성하는 역할을 의미한다.@Controller이 어노테이션이 붙은 클래스가 "MVC의 컨트롤러"임을 나타낸다.
@RequestMapping 어노테이션을 사용하여 클라이언트 요청을 특정 컨트롤러에 전달할 수 있게 해준다.stereotype annotation
https://incheol-jung.gitbook.io/docs/q-and-a/spring/stereo-type
https://milkshake91.tistory.com/5