Invalid bound statement (not found): com.example.demo.mapper.B18040208Mapper.search

这种报错,启动的时候一般不会报错,在你调用到对应的服务的时候,找不到对应的mapper文件时,报错。

有一种原因是xxxMapper.xml文件编写有问题,这个原因这里不做讨论


 

第二种:对mapper.xml文件未加扫描

启动springboot对象上添加:@MapperScan("com.example.demo.mapper"),同时在mapper文件上加上@Mapper注解


 

第三种:原因就是项目运行的时候,找不到xxxMapper.xml文件,项目编译的之后,没有这个文件。

产看编译生成target:果然找不到对应的xxxMapper

Invalid bound statement (not found): com.example.demo.mapper.B18040208Mapper.search_xml文件

因为编译的时候,没有吧xml编译过来

解决方法1:在pom.xml加上配置

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

 

 

解决方法2:(我遇见的问题是这个,因为我本身写在了resourcec下了)

 

将xml放到resources/下面,并在yml配置文件中加上如下配置,

Invalid bound statement (not found): com.example.demo.mapper.B18040208Mapper.search_解决方法_02

yml中:

Invalid bound statement (not found): com.example.demo.mapper.B18040208Mapper.search_spring_03

 

 

 

mybatis:
  mapperLocations: classpath:mapper/*.xml 

解决!