springboot整合mybatis mapper注入时显示could not autowire的错误,老是飘红。如下图:
虽然不影响运行,但是看着总是会不舒服的。
我看的网上的有两种设置方式:一种是通过设置idea,在这里就不说了。还有一种就是在mapper或者dao接口中增加@Component(“nameSpance”)这个注释,具体操作如下:
以上图中的ProductMapper为例 需要在在ProductMapper接口增加@Component(“nameSpance”)这个注释注释中的nameSpance在本例中为productMpper。具体如下图:
到此飘红就搞定