XML mapping file configuration under JAVA's Mybatis framework

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).

572ba244cecc435bac7fba6a7546a8aa.png

 

  • The namespace attribute of the XML mapping file is consistent with the fully qualified name of the Mapper interface.

c51c23bc3f8546f3a95f15f481517dbf.png

 

The fully qualified name can be obtained through the following figure:ff4e6738cbb3487b9b7d67258732e3b1.png

 

  • 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.
    a456bd1699454b6a8f798c6f1f1ef517.png

 


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"

d8349690c1b1456393b45b3eb0188800.png

 

 

Guess you like

Origin blog.csdn.net/LuoluoluoluoYan/article/details/132005703