Search code examples
spring-mvcdaoservice-layer

How does Service Layer and Data Access Object layer fit into Spring MVC architecture?


I've read that DAO layer and the service layer is a part of Model in MVC. How is it so?


Solution

  • Technically speaking DAO and Service layers aren't really "part" of MVC. They are another pattern called service layer pattern that lives on the server and supports that actions of controllers or other classes.:

    client ---- controller --|-- service ---- DAO

    MVC Pattern --------- | ---- Service Pattern

    https://martinfowler.com/eaaCatalog/serviceLayer.html

    In short you can think of MVC as the pattern that encapsulates actions of the client and the service/dao layer as the pattern that encapsulates actions on the server. They work together but neither one is a part of the other.