최대 1 분 소요

Starting Spring Framework (7)

/ @Component vs @Bean /

Heading @Component @Bean
Where? Can be usedon any Java class Typically used on methods in Spring Configuration classes
@Configuration
Ease of use Very easy. Just add an annotation You write all the code
Autowiring Yes - Field, Setter or Constructor Injection Yes - method call or method parameters
Who creates beans? Spring Framework You write bean creation code
Recommended For Instantiating Beans for Your Own Application.
Code : @Component
1: Custom Business Logic.
2: Instantiating Beans for 3rd -party libraries: @Bean

댓글남기기