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.