Invalid bound statement原因之一

1、mapper写在了java目录里面

即使你在properties里面配置了 mybatis.mapper-locations= classpath:com/lihaoyu/demo/dao/*.xml,也没有用,因为编译的时候这个xml文件并没有被自动拉到target里面,

毕竟编译的是.java文件而不是xml嘛,所以这时候应该在pom文件里面加上

image


</build>
        <resources>
            <resource>
                <directory>src/main/java</directory><!--所在的目录-->
                <includes><!--包括目录下的.properties,.xml文件都会扫描到-->
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

或者将xml文件放在resources文件下,那么就只需要配置mybatis.mapper-locations=classpath:*/mapper/*.xml 就可以了,因为构建的时候会把resources里的东西

自动拉到classpath下,注意.classpath意思就是编译后target文件夹下的classes目录.

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念