当出现org.apache.ibatis.binding.BindingException:Invalid bound statement(not found) 错误时,无外乎两种情况:

1. xml配置文件中的id名和mapper中的方法不一致;

2. 这个错误是由maven默认加载制造成的,因为写在java文件夹下,在加载的时候,只会自动加载.java文件,不加载xml文件

解决方式

1.复制xml文件到target目录中(不建议

2.把xml文件放到resources目录中(虽然resources文件会被加载,但是也不建议

3.推荐使用通过配置实现

   (1)pom.xml配置

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

注意:

*表示:一层目录

**表示:多层目录

   (2)项目application.properties配置

mybatis-plus.mapper-locations=classpath:com/guigu/eduservice/mapper/xml/*.xml

注意:这里是类路径

最终效果编译后的target目录里有了xml文件

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注