Springboot异常:Unsatisfied dependency expressed through field 'userDao'

报错信息:

Unsatisfied dependency expressed through field ‘userDao’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.rick.dao.UserDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

解决方法:

忘了扫描,对于包的扫描有两种方法:
一种是在mapper中直接加入@mapper,但是每个mapper都需要加注解
另一种是在application中加入扫描路径
@MapperScan(basePackages = "com.rick.dao")

  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
【资源说明】 1、基于springboot+mybatis实现的外卖订餐系统源码+项目说明(毕设).zip 2、该资源包括项目的全部源码,下载可以直接使用! 3、本项目适合作为计算机、数学、电子信息等专业的课程设计、期末大作业和毕设项目,作为参考资料学习借鉴。 4、本资源作为“参考资料”如果需要实现其他功能,需要能看懂代码,并且热爱钻研,自行调试。 ### 项目概述 首先来了解项目需求。 项目分为客户端和后台管理系统两个界面,客户端针对普通用户,功能包括用户登陆、用户退出、菜品订购、我的订单。 后台管理系统针对管理员,功能包括管理员登陆、管理员退出、添加菜品、查询菜品、修改菜品、删除菜品、订单处理、添加用户、查询用户、删除用户。 需求了解完之后,接下来设计系统,首先分配出4个服务提供者,account、menu、order、user。 - account - 提供账户服务:用户和管理员登陆。 - menu - 提供菜品服务:添加菜品、查询菜品、修改菜品、删除菜品。 - order - 提供订单服务:添加订单、查询订单、删除订单、处理订单。 - user - 提供用户服务:添加用户、查询用户、删除用户、用户修改。 ## 异常 - org.springframework.beans.factory.UnsatisfiedDependencyException 不满足依赖异常 - org.springframework.beans.factory.BeanCreationException - org.springframework.beans.BeanInstantiationException - org.springframework.core.NestedIOException - org.apache.ibatis.builder.BuilderException - java.lang.IllegalArgumentException ``` Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\GUSHI\IdeaProjects\springboot2\target\classes\mapping\UserRepository.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for com.m.dao.AdminDao.login at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType (AbstractAutowireCapableBeanFactory.java:1431)
Unsatisfied dependency expressed through field 'userDao'是运行时报错的一部分信息。它表示在某个类的字段'userDao'上存在一个依赖关系未满足的问题。根据引用的描述,这个错误可能是由于某个依赖关系的问题导致的。 根据引用中提供的代码片段,可能是在使用mybatis-plus-boot-starter的过程中引起了这个错误。这个依赖项可能没有正确地配置或添加到项目中。 要解决这个问题,可以尝试以下几个步骤: 1. 确保你的项目中已经添加了mybatis-plus-boot-starter的依赖项。可以检查你的项目的pom.xml文件,确保存在类似于引用中的依赖项配置。 2. 确保依赖项的版本号是正确的。检查引用中的版本号,并确保与你的项目中使用的版本号一致。 3. 检查你的代码中是否有正确的注入或配置'userDao'字段的地方。确保该字段被正确地注入或初始化。 如果以上步骤都没有解决问题,你可以参考引用中提供的错误信息,重新运行应用程序并启用'debug'模式,以获取更详细的错误报告。这有助于确定导致依赖关系未满足的具体原因,并采取相应的措施来解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [运行时报错Unsatisfied dependency expressed through field](https://blog.csdn.net/qq_45928041/article/details/122929825)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [spring boot整合mybatis-plus启动报错问题及解答.pdf](https://download.csdn.net/download/Conquer24/12686490)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值