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

3.90K viewsSpring
0

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

Manohar Changed status to publish June 16, 2019
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..!!

Manohar Changed status to publish June 17, 2019
Add a Comment
Write your answer.