SpringMVC+SpringBoot+MyBatis

 

First, in the frame sometimes you find dao layer and the service layer is the same code, why it exists at the same time? (Hereinafter https://blog.csdn.net/fanjieshanghai/article/details/88219652 invasion deleted)

service is the service layer, dao is the data access layer.
  Remember just learning programming, are in direct call service dao, a new service which will dao class object, call, did not do other meaningful things, do not understand there is this what use to work after a long will know, business is the most important task.
  We all know now the mainstream standard way of programming are based on a comprehensive MVC design pattern, MVC itself does not belong to a design pattern, which describes a structure, to achieve the ultimate goal of decoupling , the decoupling say mean you change a layer of code, the code will not affect my other layers, if you would like this framework spring, you will know oriented programming interface, call control layer, presentation layer, control layer calls the business layer, call the data access layer, the business layer. Perhaps the beginning of all new objects to call the next level, such as your new business layer objects in a DAO class, call the DAO class method to access the database, so writing is wrong, because in the business layer should not contain specific objects, most there can be only references, if there is a specific object exists, it couples. When the object does not exist, I would like to modify the code of business, this is not logical. Like a bad memory on the motherboard, I changed memory, with no need even for the motherboard. I do not know is which memory production, do not know how much capacity, as long as the memory can be plugged in to use this interface. This is the meaning of MVC.
  Meaning service went on to say, in fact, because you're doing things at different levels is not so strict, you do things in a small business itself, cite a simple example, you do a paging function, data 1000, you 20 in a page, you can write this function tools packaged together, then call this method in the business layer package where this is doing business in the real thing, as long as no access to the database, should write in the business.

  

As to why the service layer to use interface definition has the following advantages: 

  • In the java interface is a multiple inheritance, and the inheritance of a single class, if you need a class to implement multiple service, you can use the interface to achieve, with the class definition is not so flexible service

  • To provide different services database, we only need to face a different class implements the interface can be, rather than repeatedly defined class

  • Programming regulatory issues, the interface of the program is to achieve as a package together, then the caller interface is not only concerned with care to achieve, which is thought of "high cohesion, low coupling".

Two, SSM framework interface shorthand:

( Https://blog.csdn.net/it_95/article/details/84103285 invasion deleted)

Third, the article details the

https://www.cnblogs.com/shamo89/p/7090542.html (invasion deleted)

Guess you like

Origin www.cnblogs.com/21-forever/p/11417406.html