[MyBatis] Invalid bound statement (not found) summary of error resolution methods

Source: Internet
Author: User
I. Description

There are many kinds of errors caused by MyBatis invalid bound statement (not found), the main reason is that Xxxmapper.java and xxxmapper.xml are not properly bound. There are many reasons for not properly binding, so some people in the online Baidu query to other people's blog after the solution is not able to solve their own problems, here to make a summary of some methods. second, the cause of the error and solutions 2.1 Map Xxxmapper.xml File not scanned

If you are using a MAVEN-built project, the configuration file under Src/main/java is not actively loaded because MAVEN defaults to loading only the configuration files under the Src/main/resources directory. If your mybatis mapping XML file is placed in the same directory as the interface file, you must configure the following in the Pom.xml file:

<!--If you do not add this node, the MyBatis mapper.xml file will be omitted. -
	<build>
		<resources>
			<resource>
				<directory>src/main/java</ directory>
				<includes>
					<include>**/*.properties</include>
					<include>**/*. xml</include>
				</includes>
				<filtering>false</filtering>
			</resource >
		</resources>
	</build>
2.2 Interface name is inconsistent with XML mapping file name

Please check that your Xxxmapper.java file and the Xxxmapper.xml file name are the same;

namespace configuration error in 2.3xml mapping file

namespace must be equal to the full class name of the interface


2.4 The ID value of a label such as Select/delete/update/insert in an XML map file is inconsistent with the method name in the interface

The parametertype value of a label such as Select/delete/update/insert in a 2.5xml mapping file is inconsistent with the type of the parameter of the method in the interface



The type or resulttype of the resultmap of a label such as Select/delete/update/insert in an 2.6 XML map file is inconsistent with the types of the return parameters of the method in the interface

The value of DatabaseID in a label such as Select/delete/update/insert in a 2.7xml mapping file was not found in the spring configuration file



The reasons for the above collation errors are not complete, and this problem occurs later if not the above collected points I will add.

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.