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:-

7 comments:

  1. 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
  2. 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
  3. Amazing blog ! what a informative blog this is !!! java is very critical part in todays era…. If you are searching java software developer ? then i would like to suggest you intileo technologies which is highly recommend by me and so many people. Intileo technologies a best it firm locate in gurugram , haryana india. You can visit them :- https://intileo.com/

    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
  6. Great share! Amazing write-up!

    I like Your articles and your information is so clear.

    Visit our website for best Website designing services at affordable price, We are leading Website Developers in Vadodara

    ReplyDelete
  7. Awesome Article Thanks for sharing your valuable information Hire Java developer from Technoduce Dedicated resource for Java development

    ReplyDelete