Invalid bound statement (not found)异常

先说下问题:dao层接口访问不到方法 提示找不到对象 

先说下我的环境 :

  1. IDEA 
  2. SpringBoot
  3. Mybatis

mapper和entity是逆向工程生成的  前台访问报这个错误。

org.apache.ibatis.binding.BindingException:Invalid

bound statement (not found): com.lzx.school.mapper.StudentDAO.selectByExample

也就是这个方法没有找到实现。 要知道这个方法的实现是mybatis动态来做的。为什么没有实现呢 可能是mapper文件有错误

看了下我的mapper确定是没错的。咱们看看mavan 的target文件夹

 

我透 我的mapper是在这的 可是没有。百度了下是IDEA默认不会把xml生成 T.T

需要配置mavan的pom文件

如下:


<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>

    </build>

如果没改过项目目录直接复制 resources节点到项目的pom里就行了 。

废了挺久时间的 特意写了个demo

猜你喜欢

转载自blog.csdn.net/qq_37400961/article/details/81329730