警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram

org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'accountService': Unsatisfied dependency expressed through field 'accountMapper': Error creating bean with name 'org.mybatis.spring.SqlSessionFactoryBean#0': Lookup method resolution failed

出现这个异常,大部分原因是因为jar包的版本问题导致的,如果你是参考别人的代码进行配置的jar包,导入同样的依赖版本也会出现这个问题

使用百度翻译一下:

org.springframework.context支持。AbstractApplicationContext刷新
警告: 上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory。UnsatisfiedDependencyException:创建名为“accountService”的bean时出错:通过字段“accountMapper”表示的依赖关系不满意:创建名为”org.mybatis.spring“的bean时发生错误。SqlSessionFactoryBean#0”:查找方法解析失败

翻译解析

根据上面的翻译我们可以判断出来,是依赖关系的问题,通过使用必应的搜索,搜到了两篇文章关于这个问题的解决,大部分说的是依赖问题,主要是mybatis-spring依赖

问题复刻

<dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.10</version>
      <!--2022 年 5 月 23 日-->
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>2.0.7</version>
      <!--	2022 年 1 月 29 日-->
    </dependency>

通过上面的代码块可以看出来,mybatis-spring的版本是2.0.7对比3.5.10的版本差了一个版本,通过maven仓库可以看到mybatis-spring已经有3.0.0的版本了我们换上最新版本就可以了

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>3.0.0</version>
</dependency>

解决方法

就是把mybatis-spring依赖换成最新版本的就行了

参考
链接A
链接B

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值