Announcement Announcement Module
No announcement yet.
@Component vs @Service Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Component vs @Service

    Hi Guys,

    I have a simple question about annotations @Component and @Service.

    What is the difference between them, and what exactly @Service mean ? how I understand they both register a Component as Bean in Spring Context ..

    and also can anybody provide me with example of creating/using/registering nice "Services" with @Service

    Thank you

  • #2
    My understanding is that

    - @Component indicates any Spring-managed component, whereas

    - @Service is a specialisation of @Component to indicate a component in your service layer.

    Other specialisations of @Component are

    - @Repository to indicate a DAO
    - @Controller in the presentation layer

    I don't think there's much practical difference between these - but perhaps in exception translation, or if you were to write your own AOP interceptors to handle them differently.

    The relevant section of the Reference Guide is Section 3.


    • #3
      Check this section of the Spring reference guide.

      The best way to get a good response to your question is to post in the right forum. Although you may be using Spring Web Flow, you're more likely to get a helpful response in the core container forum.