SpringCloud:Injection of resource dependencies failed

报这样的错误一般会遇到下列几种情况:

情况1:注解的问题,业务实现类加@Service,映射类加@Mapper、启动类上加上@MapperScan(basePackages = "com.kingbal")以及@Resouce

情况2:命名相同,将命名修改不同即可

java 复制代码
@Resource
KingMapper xMapper;
@Resource
KingbalMapper xMapper;
或者
@Autowired
KingMapper xMapper;
@Autowired
KingbalMapper xMapper;

情况3:由于springboot的版本,降低版本即可

情况4:依赖包引入错误的

java 复制代码
// 错误的
import jakarta.annotation.Resource;
// 正确的
import javax.annotation.Resource;

问题五:application.yml或者application.properties中的项目目录路径完全一致即可

java 复制代码
mybatis:
  mapper-locations: classpath:mapper/kingbal*.xml  
  type-aliases-package: com.king.kingbal.pojo
  configuration:
    map-underscore-to-camel-case: true 
 
或
 
mybatis-plus:
  mapper-locations: classpath:/mapper/kingbal*.xml
  configuration:
    log-impl: kingbal.log
    call-setters-on-nulls: true 
相关推荐
GetcharZp12 分钟前
告别 Nginx 手动配置!这款 Go 语言开发的云原生网关,才是容器化时代的真香神器!
后端
RuoyiOffice21 分钟前
SpringBoot+Vue3 企业考勤如何处理法定假期?节假日方案、调休补班与工作日判断链路拆解
spring boot·后端·vue·anti-design-vue·ruoyioffice·假期·人力
xmjd msup1 小时前
spring security 超详细使用教程(接入springboot、前后端分离)
java·spring boot·spring
Vane11 小时前
从零开发一个AI插件,经历了什么?
人工智能·后端
952361 小时前
SpringBoot统一功能处理
java·spring boot·后端
rleS IONS2 小时前
SpringBoot中自定义Starter
java·spring boot·后端
DevilSeagull2 小时前
MySQL(2) 客户端工具和建库
开发语言·数据库·后端·mysql·服务
TeDi TIVE3 小时前
springboot和springframework版本依赖关系
java·spring boot·后端
雨辰AI3 小时前
SpringBoot3 + 人大金仓 V9 微服务监控实战|Prometheus+Grafana+SkyWalking 全链路监控
数据库·后端·微服务·grafana·prometheus·skywalking
myrh pdmd3 小时前
maven导入spring框架
数据库·spring·maven