[ CS Study ] Bean / Component Annotation

이승렬·2023년 7월 19일

[Spring]

목록 보기
10/15
post-thumbnail

#1. 차이

두 어노테이션 모두 IoC 컨테이너에 Bean을 등록하기 위해 사용합니다

@Component : 개발자가 작성한 class를 기반으로 실행시점에 인스턴스 객체를 1회(싱글톤) 생성합니다

@Controller, @Service, @Repository 는 모두 @Component 이며 실행시점에 자동으로 의존성을 주입합니다

@Bean : 개발자가 작성한 method를 기반으로 메서드에서 반환하는 객체를 인스턴스 객체로 1회(싱글톤) 생성합니다

profile
Backend_Developer

1개의 댓글

comment-user-thumbnail
2023년 7월 19일

좋은 글 감사합니다!

답글 달기