org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

开发环境:IDEA+Mybatis+Spring

错误如图:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

检查过各层注解、mapper.xml配置文件,包扫描都没问题,后来发现在编译的target/classes目录中没有mapper.xml。

 

解决办法:

在pom.xml中添加

<!--编译时增加xml文件-->
<build>
    <resources>
        <resource>
            <directory>src/main/java</directory>
            <includes>
                <include>**/*.xml</include>
            </includes>
            <filtering>true</filtering>
        </resource>
    </resources>
</build>

这样会将源码中的*mapper.xml文件编译到target/classes中。