no171
no171

Reputation: 1

When to go for @Configuration and @Component in a spring application?

We all know that both these annotations are used to create beans. But if @Component was already there to create bean then what was the need of @Configuration (which use @Bean) to create bean. Please help in understand this and in which scenario we need to use the annotation.

Upvotes: 0

Views: 93

Answers (2)

Saurabh Bhurle
Saurabh Bhurle

Reputation: 169

Suppose if you need to configure any third party class (like JdbcTemplate, Sendrgrid etc...) as spring bean then you should go with @Configuration annotation. and your business related classes as spring bean then you should go with @Component annotation.

Cheers!

Upvotes: 1

Related Questions