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