在使用springboot整合ssm时,service类自动注入mapper报错。
Could not autowire. No beans of ‘UserMapper’ type found. less… (Ctrl+F1)
Inspection info:Checks autowiring problems in a bean class.
解决办法1,在启动器上加入mapper注解扫描
@MapperScan(“xxx.mapper”)
依然会有红线,但是运行没有报错。
解决方案原文地址
https://blog.youkuaiyun.com/sinat_34979383/article/details/78674433
解决方法2,在原文下评论中找到第二种解决办法,application.properties中加入
mybatis.type-aliases-package=xxx.mapper
然后在每个mapper接口上加上@Mapper注解
依然会有红线,但是运行没有报错。
sprint boot 整合ssm 自动注入mapper报错
最新推荐文章于 2025-05-22 09:44:33 发布