What’s the difference between @Component, @Service & @Repository annotations in Spring?

2.24K viewsSpring
0

What’s the difference between @Component, @Repository & @Service annotations in Spring?Please explain

Changed status to publish
Add a Comment
0

@Component: It is a basic auto component scan annotation, it indicates the annotated class is an auto scan component.

@Controller: Annotated class indicates that it is a controller component, and mainly used at the presentation layer.

@Service: It indicates the annotated class is a Service component in the business layer.

@Repository: You need to use this annotation within the persistence layer, this acts like database repository.

I hope the above snippet works fine, please try..!!

Changed status to publish
Add a Comment
You are viewing 1 out of 1 answers, click here to view all answers.
Write your answer.