springboot整合mybatis mapper注入时显示could not autowire的解决

springboot整合mybatis mapper注入时显示could not autowire的错误,老是飘红。如下图:
Could not autowire. No beans of 'ProductMapper' type found.
虽然不影响运行,但是看着总是会不舒服的。

我看的网上的有两种设置方式:一种是通过设置idea,在这里就不说了。还有一种就是在mapper或者dao接口中增加@Component(“nameSpance”)这个注释,具体操作如下:

以上图中的ProductMapper为例 需要在在ProductMapper接口增加@Component(“nameSpance”)这个注释注释中的nameSpance在本例中为productMpper。具体如下图:
在这里插入图片描述

到此飘红就搞定

猜你喜欢

转载自blog.csdn.net/zhang_cl_cn/article/details/88901112