Saturday, 16 October 2021

Spring Stereotype Annotations

    In this post, we can learn what are the Stereotype annotations in Spring and also difference between @Component and @Bean annotations.

In Previous one of the post we discussed all Spring Annotations,  so stereotype annotations also covered but we need to see which are those Spring annotations are stereotype annotations.

     The Stereotype annotations are special type of annotations and are used to create Spring beans automatically in the application context. The Stereotype annotations are @Component, @Controller, @Service and @Repository. @Component annotation is a parent or we can say generic stereotype. The other three annotations are derived from Component annotation.

  • @Component :- Used at class level that makes the class a component.
               @Component("employee")
       class Employee{
           private String name;
           // other fields 
       }

  • @Controller:-  Used to create Spring beans at the controller layer.
                @Controller
        @RequestMapping("employee")
        public class EmployeeController {

        }
  • @Service:-  Used to create Spring beans at the Service layer.
                 @Service
        public class EmployeeService{

        }
  • @Repository:-  Used to create Spring beans for the repositories at the DAO layer.
                @Repository
        public class EmployeeRepository{

        }

Stereotype Annotations


Difference between Component and Bean annotation:-

5 comments:

  1. Excellent information provided by you through this post. I follow all the mentioned information.If you are lookig for Interview Questions and answers website then you can visit Just Crack Interview, here you will find interview questions and answers for developer, software engineer, bankers etc.

    ReplyDelete
  2. Remote monitoring can be performed in a variety of ways by DBAs. Admins can manage it through individual connections. Monitoring a database's performance can be done remotely. It is also possible to create a script to collect system performance and health data, which is then sent to the database administrator for review.
    https://genexdbs.com/

    ReplyDelete
  3. Are you searching affordable java developer? there are so many java developers but noone compare with intileo technologies. Now you will ask “how you can say that intileo technologies is best company rather than other ?” yes i am saying this with a security “intileo technologies “ is the oldest & bestest it company ever… they are providing many other services also like php web development , dot net development , softwaredevelopment also for any kind of query feel free to contact with them :- 918470058143

    ReplyDelete
  4. Project Outsourcing isn’t the answer to everything. Lots of internet marketing pundits will tell you to outsource, outsource, outsource. Having a trusted team like Intileo Technologies that knows each other and enjoys working together is good, too. Visit us :- https://intileo.com/ E mail us :- info@intileo.com Call us :- +91 8700016281

    ReplyDelete
  5. Hi, I have just started to Learn Java Online. and this blog is really informative for me. Thank you for this blog!

    ReplyDelete