Java Spring Framework: Component, Repository, Service - differences



  • Explain the difference between: ComponentRepositoryService Total Java Spring Framework

    Provide simple examples of use.



  • @Component - it's any random bin that Spring can find through. autoscan

    Example: You did some class and you want to make a copy accessible through @Autowired


    The rest of the annotations identify layers of typical multi-layer architecture:

    • @Repository - That's it. @Component with DAO-Slois semantics. The place where you go to the database. Spring's gonna make a drop-out class. DataAccessException

    • @Service - That's it. @Component with a semantic layer of business logic.

    • @Controller - That's it. @Component Semantic web complex. Such Spring bubbles will turn into earring.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2