Friday, September 17, 2021

Why @Controller,@Service and @Repository are used in spring?

We already know that if we use @Component annotation we can easily identify bean in the IOC container .Then why need to use these special annotation-

@Controller: In MVC pattern @Controller annotation used to define servlet to serve for a http request. 

@Repository :   @Repository is the special annotation for encapsulation storage, retrieval and search behavior on relational database . Their may be any exception while operating certain operation in database but some of them can be handled by using @Repositoy annotation.

@Service:   @Service annotation is used to define business layer in spring .

Specifically annotations are categorized to apply logic on them . Using AOP we can provide special logic on the annotation .

No comments:

Post a Comment

Fluent interface pattern

 public class UserConfigurationManager {     private String userName;     private String password;     private UserConfigurationManager() { ...