Loading

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目录.

 

2、

 

posted @ 2022-01-21 07:21  青岑  阅读(76)  评论(0编辑  收藏  举报