The problem of Invalid bound statement (not found) in the integration of mbatis with SpringBoot

mybatis the specific configuration in application.yml is as follows:

mybatis:
  config-location: classpath:mybatis/mybatis-config.xml
  mapper-locations: classpath*:mybatis/mapper/mysql/**/**.xml
  type-aliases-package: com.dragonflyxd.lr.web.model.entity

there is also a note to scan mapper files in the entry LrWebApplication of the project:

@MapperScan("com.dragonflyxd.lr.web.dal.**")
The screenshot of the code structure of the

Dao layer is as follows:

clipboard.png

mybatis-config:

clipboard.png

CategoryMapperMapperxml:

clipboard.png

clipboard.png


/category/test "Invalid bound statement (not found): com.dragonflyxd.lr.web.dal.CategoryMapper.count"

  • Mapperxml
  • xmlMapper
  • Mapperxml

    clipboard.png

Mar.14,2021

after investigation, it is found that the reason is that the xml file cannot be found.
because the mapper.mysql I built in the project is the name of a folder , not the package name, which does not match mapper-locations: classpath*:mybatis/mapper/mysql/**/**.xml .

also note that in IDEA , the directory, package name and file name under resources can be used . , see the screenshot below:

clipboard.png


add @ Mapper annotation to the pojo of mapper, a repository annotation cannot complete automatic assembly


modify in application.yml:

mybatis:
  mapper-locations: classpath:mybatis/mapper/mysql/*.xml

secondly: @ MapperScan changed to

@MapperScan("com.dragonflyxd.lr.web.dal")

error message is "Invalid bound statement (not found): com.dragonflyxd.lr.web.dal.CategoryMapper.count" invalid binding declaration

it is expected that the problem lies in the naming of the function CategoryMapper.count . Try changing the count () method in CategoryMapper to getCount () , and the corresponding id in mapper.xml to getCount ()

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e87696-45b9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e87696-45b9c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?