Error:
possible cause:
-
The mapper configuration file is not loaded;
solution: try both of the two ways to load the xml mapping file! -
View the compiled file (if there is no xml file, it means that mybatis or maven is not loaded)
Solution: tell maven to pack and bring the xml file
-
It may be a problem with the maven directory structure, check whether the directory complies with the maven specification
-
It may be that the value bound to the id attribute of the sql xml file is not the same as the ID of the method
When mybatis is initialized, it will put the id of sql as the key and sql as the value, and put it in a map. When it is executed, it will get sql from the map according to the method name. If the method name and the sql id are inconsistent at this time, the corresponding sql cannot be obtained. So it must be consistent
注意! 如果使用package引入mapper文件
In this case, if it is in non-annotation mode, the xml configuration file must also be under the same level of package and have the same name as the Mapper class