org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):xxx

The general reason for the above error is that mapper.xml cannot be found!

There are three reasons for this error:

  1. The path-qualified name of the namespace is inconsistent with the mapper class that needs to be mapped

Solution: Check whether the mapping path of the namespace is consistent with the mapping mapper path

  1. The sql statement id in the xml file is inconsistent with the method name in the mapper class

Solution: Check whether the method name and id are consistent.

  1. Since maven's loading mechanism only loads files with the suffix .java in the src/main/java directory, our xml files cannot be scanned.

Solution 1: Transfer our xml file to the resource directory, and create the same package as the mapper class. The above example is: com/aliyev/auth/mapper.

Solution 2: Modify the pom file and yml file

mybatis-plus: #如果你用的框架为mybatis,则改为mybatis!
    mapper-locations: classpath:com/aliyev/auth/mapper/xml/*.xml #xml文件相对路径

If the framework you use is mybatis, change the top to mybatis!

<build>
    <resources>
        <resource>
            <!--给maven指明加载xml文件-->
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
                <include>**/*.yml</include>
                <include>**/*.properties</include>
            </includes>
            <filtering>false</filtering>
        </resource>
    </resources>
<build/>

Guess you like

Origin blog.csdn.net/qq_61544409/article/details/129647249