Org.apache.ibatis.binding.BindingException "Cause Rollup"

Source: Internet
Author: User

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.

    1. 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)
    2. 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:

  1. 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
    1. For example, the interface name is Namemapper.java; the corresponding XML should be Namemapper.xml
  2. is the Mapper.xml namespace (namespace) consistent with the package name of the Mapper interface? [plain] view plain copy
    1. 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
  3. The method name of the interface, consistent with the ID of a SQL tag in XML [HTML] view plain copy
    1. For example, the interface method list<User> FindAll (); Then there must be one in the corresponding XML <select id="FindAll" resultmap="* *">****</Select>
  4. 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
  5. 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
    1. <resources>
    2. <resource>
    3. <directory>src/main/java</directory>
    4. <includes>
    5. <include>**/*.xml</include>
    6. </includes>
    7. <filtering>true</filtering>
    8. </Resource>
    9. </Resources>

I was the pit in the 5th, tossing for four hours, we found in time.

Org.apache.ibatis.binding.BindingException "Cause Rollup"

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.