결론
외부 라이브러리를 사용해야 할 때는 우리가 직접 @Component를 그 라이브러리에 선언할 수 없으므로, @Configuration + @Bean 조합으로 스프링 빈을 생성하고, 그 외에 우리가 직접 제어할 수 있는 클래스들은 @Component를 붙임으로써 자동으로 스프링 빈으로 등록되도록 하자.
[참고자료]
When should you use @Configuration instead of @Service/@Controller/@Component for defining beans
I am trying to understand the Spring Framework better and my question is basically: What is the benefit of the @Configuration annotation compared to @Service/@Controller/@Repository (or @Component ...
stackoverflow.com
https://stackoverflow.com/questions/10604298/spring-component-versus-bean
Spring: @Component versus @Bean
I understand that @Component annotation was introduced in spring 2.5 in order to get rid of xml bean definition by using classpath scanning. @Bean was introduced in spring 3.0 and can be used with @
stackoverflow.com
'Spring Boot' 카테고리의 다른 글
@Autowired와 Collection 클래스(List, Map, etc.) (2) | 2023.12.05 |
---|---|
@Autowired와 @Qualifier, @Primary (3) | 2023.12.05 |
@Autowired required 옵션 (0) | 2023.12.02 |
다양한 의존관계 주입 방법 (@Autowired) (0) | 2023.12.02 |
@Autowired로 의존관계 주입하기 (1) | 2023.12.02 |