Sunday, August 21, 2022

@Component vs @Bean

 

@Component is suitable for component scanning and automatic wiring.

Sometime an automatic configuration is not an option. When?

Let’s imagine that you want to wire components from 3rd party libraries (you don’t have source code so you can’t annotate its classes with @Component), so automatic configuration is not possible.

The @Bean annotation returns an object that spring should register as bean in application context. The body of the method bears the logic responsible for creating the instance.

No comments:

Post a Comment

Ruby Basics

Basics of Ruby   Start Ruby interpret On terminal just type rib ruby_docs $ irb 3 . 0 . 0 : 001 > name = "This is the first ...