Spring @Component, @Service, @Repository, @Controller Difference Major difference between these stereotypes...

Please Visit: http://ift.tt/1ajReyV



Spring @Component, @Service, @Repository, @Controller Difference

Major difference between these stereotypes is they are used for different classification.

In a multitier application, we will have different layers like presentation, service, business, data access etc. When a class is to be annotated for auto-detection by Spring, then we should use the respective stereotype as below.

@Component – generic and can be used across application.

@Service – annotate classes at service layer level.

@Controller – annotate classes at presentation layers level, mainly used in Spring MVC (Link->http://ift.tt/1sEVRyJ) .

@Repository – annotate classes at persistence layer, which will act as database repository.http://ift.tt/1sEVRyN

http://ift.tt/1sEVOTD



Spring @Component, @Service, @Repository, @Controller Difference







from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1qwGjj9

via LifeLong Community

No comments:

Post a Comment