Spring Boot多模块项目启动时出现UnsatisfiedDependencyException异常

文章作者通过删除未使用的mapper文件解决了UnsatisfiedDependencyException问题。他们发现,虽然可以提前导入某些依赖如redis,但尚未使用的、被框架注入为bean的代码不应提前编写,这可能导致异常。删除无关组件是解决问题的一种有效策略。

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

网上对于这个异常已经有很多优秀文章了,但是没有解决我的问题。

我的解决方法是将还没用到的mapper文件给删除掉,这样下面两个问题就解决啦。

  1. UnsatisfiedDependencyException

  2. sqlexception

总结就是除了需要连接类似redis依赖,其它的依赖可以提前导入,但是有一些被框架注入为bean的代码,暂时没有用到的话不能提前编写。

2025-03-27 15:35:22.815 ERROR 26436 - [restartedMain] [o.s.b.web.embedded.tomcat.TomcatStarter,onStartup,61] : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'jwtFilter': Unsatisfied dependency expressed through field 'jwtUtil'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'jwtUtil': Unsatisfied dependency expressed through field 'userCache'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userCache': 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 'userGroupService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'groupServiceImpl': Unsatisfied dependency expressed through field 'departmentService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'departmentServiceImpl': Unsatisfied dependency expressed through field 'deptUserService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptUserServiceImpl': Unsatisfied dependency expressed through field 'userSetupService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userSetupServiceImpl': Unsatisfied dependency expressed through field 'roleService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'roleServiceImpl': Unsatisfied dependency expressed through field 'rolePrivService'; nested exception is org.springframework.beans.factory.UnsatisfiedDepend
最新发布
03-28
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值