Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection do

Error:
Insert picture description here
possible cause:

  1. The mapper configuration file is not loaded;
    Insert picture description here
    solution: try both of the two ways to load the xml mapping file!

  2. View the compiled file (if there is no xml file, it means that mybatis or maven is not loaded)
    Insert picture description here
    Solution: tell maven to pack and bring the xml file
    Insert picture description here

  3. It may be a problem with the maven directory structure, check whether the directory complies with the maven specification

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

Insert picture description here

注意! 如果使用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
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44313584/article/details/115022487