[idea breakpoint error] Several troubleshooting methods for org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

When running the project, use the idea breakpoint and report the error org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.springboot.userlogin.springbootdemo.dao.UserDao.getUserByMassage

Insert image description here
Reason: There is a problem when mapping and binding the dao interface and mapper configuration file in mybatis, that is, the interface and xml are either not found, or they are found but cannot match.

Troubleshooting method:

1. Whether the annotation @Mapper is used on the mapper.java file or whether the Mapper class @MapperScan("com.heima.model.mappers") is scanned on the startup class [note whether the scanned package name is correct]< /span>
Insert image description here
2. Pay attention to whether the namespace in the mapper.xml file correctly points to the location of the Mapper.java class []
Insert image description here

3. Pay attention to the consistency of the called method name in mapper.xml with the id in dao.java
Insert image description here
Insert image description here
4. Pay attention to the parameterType of the mapper.xml method
Insert image description here
5. Note that dao.java needs to be injected with @Autowired where it is called
Insert image description here
6. The mapper mapping file needs to add the xml suffix
Insert image description here

Guess you like

Origin blog.csdn.net/m0_47791238/article/details/135007326