Where to put business logic in spring mvc framework?

后端 未结 3 984
别跟我提以往
别跟我提以往 2020-12-23 10:12

I don\'t know where to put the business logic in spring mvc because I\'m new to it. I have a clue on what to do but because of lack in knowledge in spring mvc, I don\'t know

3条回答
  •  情深已故
    2020-12-23 10:38

    Many people would recommend to add the business logic to the service layer. I personally find out that's not a great idea, specially when you start testing: you may have to deal either with the persistence and business logic at the same time, or mocking everything around, and then things can get very messy.

    I do recommend reading this article before taking any conclusions: The Biggest Flaw of Spring Web Applications

    Resuming, the idea would be to move the business logic to the model layer and simplify your services methods.

提交回复
热议问题