SpringBoot启动报错"Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Err"

6 篇文章 0 订阅
3 篇文章 0 订阅

启动报如下异常:无法创建Mybatis的映射接口Bean类

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'userDaoMapper' defined in file [E:\WebProject\

这里写图片描述

这个问题找了我两天左右的时间,又是改注解又是重新写一个项目Demo来排查这个问题
后来才在poml文件找到问题所在.问题是我poml文件引入了两个Mybatis依赖包.一个是整合SpringBoot的,一个是整合Spring的jar包.两个一起出现,起冲突了

这里写图片描述

把Spring的Mybatis去掉既可以了!

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
根据提供的引用内容,nacos启动报错ERROR Startup errors : org.springframework.beans.factory.UnsatisfiedDependencyException,这个错误通常是由于依赖注入问题引起的。具体来说,可能是某个bean的依赖项无法满足,或者依赖项没有正确注入。解决此问题的方法如下: 1.检查nacos配置文件是否正确,特别是数据库连接信息是否正确。 2.检查nacos依赖项是否正确,特别是版本是否匹配。 3.检查nacos启动日志,查看哪个bean无法满足依赖项,然后检查该bean的依赖项是否正确注入。 4.如果无法确定问题所在,可以尝试使用调试器进行调试,以查找问题。 下面是一个可能的解决方案: ```java org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘xxxController’: Unsatisfied dependency expressed through field ‘xxxService’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘xxxServiceImpl’: Unsatisfied dependency expressed through field ‘xxxRepository’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘xxxRepository’: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.xxx.xxx.xxx ``` 根据上述错误信息,我们可以看到,xxxRepository这个bean的初始化方法失败了,原因是它不是一个受管理的类型。这通常是由于没有在应用程序上下文中注册该类型引起的。解决此问题的方法是在应用程序上下文中注册该类型,例如: ```java @Configuration @EnableJpaRepositories(basePackages = "com.xxx.xxx.xxx") @EntityScan(basePackages = "com.xxx.xxx.xxx") public class AppConfig { // ... } ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值