使用Mybatis-Plus时,注入mapper提示Could not autowire. No beans of ‘xxxMapper‘ type found.

本文解决使用Mybatis-Plus时遇到的注入Mapper提示Couldnotautowire错误,提供降低IDEA报错等级及添加@Component注解两种方法,确保项目正常运行。

使用Mybatis-Plus时,注入mapper提示Could not autowire. No beans of 'xxxMapper' type found.的解决方案

如图

Could not autowire. No beans of 'xxxMapper' type found.

Tips

此报红不影响项目的正常运行

解决方案

  1. 降低IDEA报错的等级
    把Error改成Warning或者其他
    虽然依然提示Could not autowire,但是不报红虽然依然提示Could not autowire,但是不报红

2.在Mapper接口上添加 @Component(value = “xxxMapper”)注解
在Mapper接口上添加@Component注解
此时就不再提示Could not autowire. No beans of ‘xxxMapper’ type found。不再提示Could not autowire

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值