This is the fifth day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021
Many Java students mock themselves as Spring engineers, but sadly, many front-end students don’t even realize they are Vue engineers
Well, that’s me!
Why study Mybatis
Recently, my friend introduced a convenient management system for separating front and background: Ruoyi. I believe many friends have used or heard of it.
The base page looks like this:
In order to avoid tying yourself to a framework, it is always helpful to learn more.
If the database component used is Mybatis, also through the more text, the system to learn about Mybatis.
Mybatis official document
At present, I study according to this set of official website documents.
If follow the mybatis framework
According to the programmer’s intuition and if according to the framework of the simple tutorial to do a simple page, the execution of a few simple SQL, roughly clear mybatis framework. The framework of Ruoyi roughly has the following parts:
controller
Controller is basically in admin in the framework:
service
Service is divided into sub-modules based on functional modules, such as Common, Framework, system, etc. If you need your own business module, you can create a new Modeul. (This shows that JetBrain Idea really works.)
Mybatis architecture
Mybatis is mainly reflected in the System section of Zoe. The screenshot of the project in the System section is as follows:
You can clearly see that there are domain, Mapper, Service folders, and XML file packages for storing SQL.
domain
Domain, also commonly referred to as DO, domain Object, the concept found on the Internet is: from the real world abstract out of the tangible or intangible business entity.
mapper
Mybatis basic universal mapper, through the configuration can automatically generate a single table to add, delete, change, check. This is used to reduce development costs and reduce the workload of programmers.
service
This basically has nothing to do with Mybatis, is to provide upward service method, generally should be a complete business method.
The mybatis configuration
Where is Mybatis configured?
Based on the experience of other frameworks in the past, we can start with the Spring configuration file and find it in the admin section: