1. Configuration specifications
- The name of the XML mapping file is consistent with the name of the Mapper interface, and the XML mapping file and the Mapper interface are placed under the same package (the same package has the same name).
- The namespace attribute of the XML mapping file is consistent with the fully qualified name of the Mapper interface.
The fully qualified name can be obtained through the following figure:
- The id of the sql statement in the XML mapping file is consistent with the method name in the Mapper interface, and the return type is kept consistent.
Note: When creating a file under resources, since there is no java file option, select the directory option directly. Do not use dots (".") to separate files when naming, because they are directory files and should be separated by "/".
For xml constraints, you can go to "mybatis Chinese website" → "Getting Started" → scroll down to find "Explore mapped SQL statements"