Results 1 to 3 of 3

Thread: @Component vs @Service

  1. #1
    Join Date
    Jan 2009
    Location
    Armenia, Yerevan
    Posts
    34

    Default @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. #2
    Join Date
    Apr 2009
    Posts
    1

    Default

    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.
    http://static.springframework.org/sp...spath-scanning

  3. #3
    Join Date
    Nov 2008
    Posts
    742

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •