Maven project mybatis Invalid bound statement (not found) solution, mavenmybatis

Source: Internet
Author: User

Maven project mybatis Invalid bound statement (not found) solution, mavenmybatis

Recently, I want to learn about the mybatis framework because of my work needs. After adding some dependencies, use mybatis to perform crud operations on the database. However, during the test, mybatis: Invalid bound statement (not found) is always reported ). After searching online for a long time, I finally found the problem. Now I have recorded it for your reference:

During the development of mapper proxy, the programmer must observe some specifications before mybatis can implement the proxy object of the mapper interface.
Its specifications are as follows:

  • The namespace of ER er. xml needs to write the full name of the ing interface class name.
  • The id of each statement in mapper. xml must be the same as the method name of the interface method.
  • The parameterType of each SQL statement defined in mapper. xml must be of the same type as that of the interface method.
  • The resultType of each SQL statement defined in mapper. xml must be of the same type as the return value of the interface method.
  • Mapper. xml must be in the same package as the corresponding mapper interface.
  • The mapper. xml Naming Rules comply with: interface name + Mapper. xml

If the above check is complete, the project complies with the above specifications, and your project is a Maven project. However, when running the program, the Mybatis invalid bound statement (not found) problem still occurs. In this case, you need to modify the pom. xml file. Add the following code to pom. xml:

1 <build> 2 <resources> 3 <resource> 4 <directory> src/main/java </directory> 5 <! -- This configuration is indispensable; otherwise, mybatis Mapper. xml will be lost --> 6 <des> 7 <include> **/*. xml </include> 8 </des> 9 </resource> 10 <! -- Specify the resource location --> 11 <resource> 12 <directory> src/main/resources </directory> 13 </resource> 14 </resources> 15 </build>

 

Add the above Code to pom. xml, run the project, and solve the problem.

Reprinted: https://blog.csdn.net/qasrc6/article/details/52796323

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.