Analysis of the error message and cause of MapperRegistry in Mybatis,

Source: Internet
Author: User

Analysis of the error message and cause of MapperRegistry in Mybatis,
MapperRegistry error occurs when you use the Mybatis interface programming instead of directly using the SqlSession instance to directly execute ing SQL statements. Error message: org. apache. ibatis. binding. bindingException: org. apache. ibatis. binding. mapperRegistry. getMapper (MapperRegistry. java: 47) org. apache. ibatis. session. configuration. getMapper (Configuration. java: 745) org. apache. ibatis. session. defaults. defasqlsqlsession. getMapper (defasqlsqlsession. java: 292) com. szcport. test. test. main (Test. java: 47)

The reason can be divided into three categories, which are summarized here.

1. The mapper configuration file of Mybtis specifies the path of the ing xml file, for example:

 

In this case, the namespace of the mapping File is incorrectly written. The correct method of the namespace of the mapping File is as follows:

 

2. Mybtis configuration file mapper uses package scanning, such:

 

In this case, the ing xml file and the mapper interface must be in the same package.

 

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.