Search code examples
spring-bootmybatisspring-mybatis

How to config mybatis mapper xml files in Spring boot's application.yml


I am a newbie to spring boot and I want to make my spring boot application integrate with mybatis and mysql database. I generate the entity,mapper interfaces,and the mapper xml files with the generator. And I also use @MapperScan annotation to tell the application how to find the mappers, my application.yml looks like following:

spring:
  datasource:
    username: root
    password:
    url: jdbc:mysql://localhost:3306/bidding
    driver-class-name: com.mysql.jdbc.Driver

mybatis:
  mapperLocations: classpath:mapping/*.xml

But when I run the application with command 'mvn spring-boot:run', it always give me the error message 'Invalid bound statement (not found)'.

Is there anything I missed in my code?


Solution

  • Something wrong with the mapping of mybatis interface and xml.

    1. check package of interface and xml ,they should be the same package
    2. check the namespace in xml and package of xml,they should be same path