日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

解决:UnsatisfiedDependencyException

發布時間:2023/12/20 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 解决:UnsatisfiedDependencyException 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

項目場景:

提示:springboot + mybatis plus


問題描述:

重點報錯信息:

  • Specified class is an interface
  • org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bankAllocationDao' defined in file [/...
  • Unsatisfied dependency expressed through field 'bankDao'
  • Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-05-28 00:01:26.426 [main] ERROR org.springframework.boot.SpringApplication:837 - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bankController': Unsatisfied dependency expressed through field 'bankService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bankServiceImpl': Unsatisfied dependency expressed through field 'bankDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bankDao' defined in file [/.../target/classes/org/.../product/bank/dao/BankDao.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [....dao.BankDao]: Specified class is an interfaceat org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bankServiceImpl': Unsatisfied dependency expressed through field 'bankDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bankDao' defined in file [/.../BankDao.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [...dao.BankDao]: Specified class is an interface... 20 common frames omitted

    原因分析:

    大致原因:dao接口無法創建bean,導致service層依賴無法注入,導致controller層依賴無法注入

    歸根結底:又一個bean創建失敗

    ?

    匯總了許多網上的辦法:

  • controller層service層dao層注解是否都使用正確?
  • 接口有沒有寫實現類,實現類實現的接口是否正確?
  • xml映射文件里路徑大小寫類型是否正確?
  • 有重復命名的xxxMapper.xml文件嗎?
  • 接口名字是否重復?

  • 解決方案:

    最終解決是第五條:接口名字是否重復,但是!重點是:非Spring提供的報錯信息中的這個接口與其他重復,而是與報錯信息毫無相關的兩個接口名字有重復。

    如果,前四條檢查后沒有解決問題,重命名報錯中接口名字后仍無見效,請每一個接口的檢查,就是這么吐血。

    ?

    總結

    以上是生活随笔為你收集整理的解决:UnsatisfiedDependencyException的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。