Error creating bean with name ‘sqlSessionFactory’ defined in class path resource


原文鏈接:這里
0.報錯描述

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/spring-mybatis.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy


看了好多,報錯結果相同,原因不一定相同。具體問題具體分析。


翻譯一下,主要有幾個方面
(1)未找到名稱為sqlSessionFactory的Bean

(2)創建類路徑資源中定義的名為“sqlSessionFactory”的bean時出錯(3)設置屬性值時出錯(4)屬性“dataSource“ 引起異常(5) 沒有發現springframework/jdbc/datasource….


一開始我以為我的數據源寫錯了,檢查了好一會,改了一些地方,但是還是不對。最終發現是最后一個的問題,還是包的問題,引入這個包以后,就正常了。


   <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.0.0.RELEASE</version>
   </dependency>

注意:版本號一定要上下對應好。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM