Invalid bound statement (not found)

  1. 项目初构建好后注入Mapper 提示 Could not autowire. No beans of 'xxxxMapper' type found ,要给映射接口加个@Component接口
  2. vhr项目构建好的第二个问题,后端接口,用了springsecurity,但是login页面登录却说Invalid bound statement (not found),后台也报错
    翻阅资料发现这种情况出现有这几种情况:
  • mapper.xml 里面的 namespace与实际类不一样
  • mapper接口的函数名称和mapper.xml里面的标签id不一致
  • 构建没有进去,请看一下target文件夹下面这些是否存在xml文件,没有请重新构建
  • 扫包是否添加,一般在springboot启动类上面加注解
    @MapperScan("club.popolee.vhr.mapper")
    

我恰巧属于第三种情况,然后解决方案是在pom.xml 里面加打包的配置如下

<build>
  <resources>
       <resource>
           <directory>src/main/resources</directory>
       </resource>
       <resource>
           <directory>src/main/java</directory>
           <includes>
               <include>**/*.xml</include>
           </includes>
       </resource>
   </resources>
</build>

最奇怪的事情来了,我本来的pom.xml里就有这个配置,但是没生效,xml文件打包还是没进target里面,然后我就把<include>**/*.xml</include>改为<include>**/*</include>,改了后就莫名其妙可以了,大无语事件!

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值