Mybatis error reporting: there are many reasons for invalid bound statement (not found), but just like the error reporting prompt, the SQL statement in XML cannot be found. There are three types of error reporting:
The first: syntax 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 Datas -->
<delete id="delete" parameterType="java.lang.String">
DELETE FROM xxx WHERE id=#{id}
</delete>
</mapper>
Check:
Is the method name (delete) in the interface consistent with id = "delete"
in the XML file
Is the path in namespace = "XXX. XXX. XXX. Mapper"
in the XML file consistent with the path in the interface file
Whether the parametertype
type and resulttype types are accurate; Resultmap is different from resulttype
Second: compilation error
Navigate to the project path: under the error path in target \ classes \
, find out whether the corresponding XML file exists
(1) . if there is no corresponding XML file, you need to add the following code to 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 appears
(2) If there is an XML file, open the XML file and check whether the error part is consistent with the source file. If it is inconsistent,
first clear the files in the classes folder and execute the command: MVN clean
clean the content and recompile it
Third: configuration error
There was a problem with the configuration path when specifying the scan package in the configuration file
for example, : the package name of the “basepackage” attribute in the spring configuration file must be specific to the package where the interface is located, and do not write the package of the parent level or higher, otherwise problems may occur; Cn. Dao and CN. * may also cause errors; During annotation scanning, packages may not be scanned
Similar Posts:
- [Solved] Springboot Error: invalid bound statement (not found)
- [Solved] Springboot Project mybatis Error: Invalid bound statement (not found)
- [Solved] Mybatis Error: Invalid bound statement (not found)
- [Solved] Mybatis: the binding mapper cannot be found Error: Org.apache.ibatis.binding.bindingexception: invalid bound statement (not found)
- [Solved] Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
- MyBatis Error: Error building SqlSession [How to Solve]
- [Solved] Browser Error: Failed to decode downloaded font and OTS parsing error: Failed to convert *** font to ***
- [Solved] Could not find resource com/cth/dao/UserImpl.xml & Single mapping file not found
- [Solved] mybatis Multi-Module Error: Invalid bound statement (not found)
- After introducing mybatisplus, the user-defined method is used to solve the invalid bound statement (not found) error