Mybatis reports an error: Invalid bound statement (not found). There are many reasons, but just like the error message, the SQL statement in the xml cannot be found. There are three situations in which the error is reported:
The first type: grammatical error
Java DAO layer interface
public void delete(@Param("id")String id);
Mapper.xml file corresponding to Java
<? xml version="1.0" encoding="UTF-8" ?> <! DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis -3-mapper.dtd" > < mapper namespace ="xxx.xxx.xxx.Mapper" > <!-- Delete data --> < delete id ="delete" parameterType ="java.lang.String" > DELETE FROM xxx WHERE id=#{id} </ delete > </ mapper >
Check: 1. Whether the method name (delete) in the interface is consistent with id=”delete” in the xml file
2. Whether the path in namespace=”xxx.xxx.xxx.Mapper” in the xml file is consistent with the interface file path
3. Whether parameterType and resultType are accurate; resultMap and resultType are different.
The second: compilation error
Locate the project path: under the error path in target\classes\, and look for the corresponding xml file.
(1) If there is no corresponding xml file, you need to add the following code in pom.xml:
< build > < resources > < resource > < directory > src/main/java </ directory > < excludes > < exclude > **/*.java </ exclude > </ excludes > </ resource > < resource > < directory > src/main/resources </ directory > < includes > < include >**/*.* </include > </ includes > </ resource > </ resources > </ build >
Delete the files in the classes folder, recompile, and the corresponding xml file will appear.
(2) If there is an xml file, open the xml file and check whether the error part is consistent with the source file.
First clear the files in the classes folder, execute the command: mvn clean to clean up the content, and then recompile.
The third type: configuration error
When specifying the scan package in the configuration file, there is a problem with the configuration path. For example: the “basePackage” attribute package name specified in the spring configuration file must be specific to the package where the interface is located, instead of writing the parent or higher level package, otherwise problems may occur; cn.dao and cn.* may also cause errors ; When the annotation is scanned, the package may not be scanned.
Read More:
- [Solved] mybatis plus Error: Invalid bound statement (not found)
- [Solved] Mybatis-plus Error: mybatisplus-Invalid bound statement (not found): com.integration.dao.ApiDao.getList
- Mybatis-plus calls its own method error: Invalid bound statement
- How to Solve org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) Error
- SpringBoot uses MyBatis error: Error invoking SqlProvider method (tk.mybatis.mapper.provider.base.BaseInsertProvider.dynamicSQL)
- The @RestControllerAdvice annotation does not take effect in the Springboot project
- Error: array bound is not an integer constant before ‘]’ token
- The imported project “c:\Microsoft.Cpp.Default.props” was not found
- [Solved] SpringBoot Project Start Error: No bean named ‘org.springframework.context.xxxxx.importRegistry‘ available
- IDEA: How to Solve Springboot Project install Error
- [Solved] Springboot Project Startup Error: Error starting ApplicationContext
- Error starting vue project these dependencies were not found:create in ./src/router/modules/md.js
- Gradle Package Project Lombok Not Working: No serializer found for class com.qbb.User and no properties discovered to create BeanSerializer……
- [Solved] Bat starts springboot project error: ERROR org.springframework.boot.SpringApplication -Application run failed
- MyBatis: Mapped Statements collection does not contain value for xxx
- Springboot configuration project access path URL root path
- [Solved] Springboot project Create to start Error: APPLICATION FAILED TO START
- ORA-24338 statement handle not executed [How to Solve]
- [Solved] Mybatis uses the PageHelper paging plugin error: Could not find method on interface ibatis.executor.Executor named query.
- [Solved] Springboot Project Startup Error: Error running XXX. Command line is too long.