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 @   青岑  阅读(82)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
历史上的今天:
2021-01-21 axios拦截器的使用
点击右上角即可分享
微信分享提示
主题色彩