UnsatisfiedDependencyException: Error creating bean with name ‘userController‘ 已解决

启动SpringBoot出错

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userController’: Unsatisfied dependency expressed through field ‘userService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userServiceImpl’: Unsatisfied dependency expressed through field ‘baseMapper’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.shuang.mapper.UserMapper’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

原因

@MapperScan(“com.xxx.mapper”) 没写或者写错
该注解可以写在SpringBootApplication启动类上或者在自定义配置类上

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
根据你提供的引用内容,Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController' defined in file是由于"userController"类的依赖注入失败导致的异常。在你的代码中,"UserService"的实现类需要添加@Component注解来进行自动注入。你可以将@Component注解添加到"UserServiceImp"类的上面,代码如下所示: ``` @Component public class UserServiceImp implements UserService { @Autowired private UserRepository userRepository; //其他代码 } ``` 这样就会解决依赖注入失败的问题。另外,还要确保在application.properties文件中没有添加错误的配置。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [报错org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name....](https://blog.csdn.net/weixin_46591043/article/details/129987134)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name](https://blog.csdn.net/weixin_44520739/article/details/88427336)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值