Background: Spring Integration MyBatis
Error: Org.apache.ibatis.binding.BindingException:Invalid bound statement (not found)
Explanation: That is, your mapper interface, after being injected by spring, is unable to use mapper.xml SQL normally;
The spring injection here means that your interface has been successfully scanned, but when spring tries to inject an implementation class for an agent (Mybatista implementation), it does not work properly. There are several possible situations here.
- The interface has been scanned, but the proxy object is not found, and even if an attempt is injected, it is injected with an incorrect object (possibly null)
- The interface has been scanned, the proxy object is found, it is injected into the interface, but it is not available when a specific method is called (other methods may be normal)
Of course, we do not say that is the case, after all, the results of the error is the same, here are a few ways to troubleshoot:
- is the mapper interface and Mapper.xml under the same package? is the name the same (only the suffix is different)? [plain] view plain copy
- For example, the interface name is Namemapper.java; the corresponding XML should be Namemapper.xml
- is the Mapper.xml namespace (namespace) consistent with the package name of the Mapper interface? [plain] view plain copy
- For example, the package name of your interface is Com.abc.dao, the interface name is Namemapper.java, then your mapper.xml namespace should be Com.abc.dao.NameMapper
- The method name of the interface, consistent with the ID of a SQL tag in XML [HTML] view plain copy
- For example, the interface method list<User> FindAll (); Then there must be one in the corresponding XML <select id="FindAll" resultmap="* *">****</Select>
- If the return value in the Interface list collection (not knowing the other collection is also), then the configuration in the XML, as far as possible with RESULTMAP (ensure that the RESULTMAP is configured correctly), do not use Resulttype
- Finally, if your project is a MAVEN project, please take a look at the directory where the interface is compiled, and it is likely that the corresponding XML file is not being produced, because Maven does not compile by default, so you need to pom.xml in your <build></build > inside, add such a paragraph:[HTML]View PlainCopy
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- <filtering>true</filtering>
- </Resource>
- </Resources>
I was the pit in the 5th, tossing for four hours, we found in time.
Org.apache.ibatis.binding.BindingException "Cause Rollup"