Question: what is the difference between @component and @bean?
Answer: Both approaches aim to register target type in Spring container. The difference is that @Bean is applicable to methods, whereas @Component is applicable to types. Therefore when you use @Bean annotation you control instance creation logic in method's body (see example above). With @Component annotation you cannot.