org.apache.ibatis.binding.BindingException

Time:2021-3-3

org.apache.ibatis.binding.BindingException

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

In mybatis, there is a problem when the Dao interface and mapper configuration file are mapped and bound. To put it simply, the interface and XML are either not found, or they are found but not matched.

Mapper interface development needs to follow the following specifications:
  1. Mapper.xml The namespace in the file is the same as the classpath of the mapper interface.
  2. Mapper interface method name and Mapper.xml The ID of each statement defined in is the same
  3. Input parameter types and methods of mapper interface mapper.xml The parametertype of each SQL defined in is of the same type
  4. Mapper interface method output parameter type and mapper.xml The resulttype of each SQL defined in is the same
Then I reported this error myself. After two days of searching for different names, I finally found that the reason for the problem is that the paths of XML and mapper interfaces under resources are different. The package name I created here is com.health.mapper Instead of creating a folder level by level, it creates a com.health.mapper Name of a bag, see the picture:

org.apache.ibatis.binding.BindingException
The right thing to do is this:
org.apache.ibatis.binding.BindingException

So we need tocom/health/mapperCreate it like this