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
出現(xiàn)這個(gè)異常,大部分原因是因?yàn)閖ar包的版本問題導(dǎo)致的,如果你是參考別人的代碼進(jìn)行配置的jar包,導(dǎo)入同樣的依賴版本也會(huì)出現(xiàn)這個(gè)問題
使用百度翻譯一下:
org.springframework.context支持。AbstractApplicationContext刷新
警告: 上下文初始化期間遇到異常-取消刷新嘗試:org.springframework.beans.factory。UnsatisfiedDependencyException:創(chuàng)建名為“accountService”的bean時(shí)出錯(cuò):通過字段“accountMapper”表示的依賴關(guān)系不滿意:創(chuàng)建名為”org.mybatis.spring“的bean時(shí)發(fā)生錯(cuò)誤。SqlSessionFactoryBean#0”:查找方法解析失敗
翻譯解析
根據(jù)上面的翻譯我們可以判斷出來(lái),是依賴關(guān)系的問題,通過使用必應(yīng)的搜索,搜到了兩篇文章關(guān)于這個(gè)問題的解決,大部分說(shuō)的是依賴問題,主要是mybatis-spring依賴
問題復(fù)刻
<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>
通過上面的代碼塊可以看出來(lái),mybatis-spring的版本是2.0.7對(duì)比3.5.10的版本差了一個(gè)版本,通過maven倉(cāng)庫(kù)可以看到mybatis-spring已經(jīng)有3.0.0的版本了我們換上最新版本就可以了
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.0</version>
</dependency>
解決方法
就是把mybatis-spring依賴換成最新版本的就行了文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-559330.html
參考
鏈接A
鏈接B文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-559330.html
到了這里,關(guān)于警告: Exception encountered during context initialization - cancelling refresh attempt: org.springfram的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!