SpringBoot integration MyBatis, BindingException problem

In the spring boot integration mybatis learning process you should frequently encountered mybatis abnormal " BindingException: Invalid bound of Statement (not found) ";

Most often online to find the reasons are attributed to the following reasons:

  •  namespace mapper interfaces with the full package path mapper.xml files are inconsistent
  •  Where the label mapper.xml file sql statement is inconsistent with the id attribute method name mapper interface
  •  Chinese annotation reason mapper.xml file (this feeling a bit crap, mybatis the dtd will not write so bad, with Chinese comments on the inseparable zone?)

 

But personal feeling, there is a reason for the situation is most likely to encounter this problem:

  Most SpringBoot tutorials, mostly recommend the mapper.xml file written in a sub-package java folder, such as java / com /.../.../ mapper or java / com / ... / ... under / dao so this type of package. But the project itself is springboot maven project (but mostly dependent on the version referred springboot-starter-parent to solve), and the default maven project resource path is main / resources, so the xml resource maven in java path is not active scanning, so the spring boot tutorial, many have overlooked this important point.

 

  If you put the xml file follow the tutorial recommended path, so be sure path to manually configure resource projects, so maven active scan xml file:

<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*xml</include>
        </includes>
    </resource>
    <resource>
        <directory>src/main/resources</directory>
    </resource>
</resources>    

 

Guess you like

Origin www.cnblogs.com/flincasnote/p/10956958.html