1. 程式人生 > >Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e

Cannot convert value of type [java.lang.String] to required type [javax.sql.DataSource] for property 'dataSource': no matching e

無法將你的datasource裡配置的字串轉換成javax.sql.DataSource物件,導致SessionFactory無法完成,datasource配置肯定有誤,檢查[/WEB-INF/applicationContext.xml]檔案中的datasource相關的配置。或者貼出來讓大家看看。
<property name="dataSource" value="dataSource">
配置錯了,這寫法Spring會以字串方式注入,報型別不匹配異常,改為
<property name="dataSource" ref="dataSource"/>