运行SpringBoot项目报错org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bea

本文主要讨论了Spring Boot应用中遇到的UnsatisfiedDependencyException异常,该异常通常由于依赖注入失败引起。解决方法包括在启动类中添加@MapperScan和@ComponentScan注解,确保Service实现类和Mapper接口上有正确的注解。通过这些步骤,可以排查并修复Spring Boot应用的依赖注入问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘loginController’: Unsatisfied dependency expressed through field ‘userService’;
解决办法:
检查启动类是否加上如下注解:
@MapperScan(basePackages = {“com.xx.xx.mapper”}, markerInterface = BaseMapper.class)
@ComponentScan(basePackages = {“com.xx.xx”})
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})

  1. 检查service的实现类上是否加上了注解 @Service

  2. 检查mapper接口类上面是否加了注解:@Mapper

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值