关于org.springframework.beans.MethodInvocationException: Property ‘dataSource’ threw exception
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property ‘dataSource’ threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
at
…
检查applicationCOntext.xml配置文件:
<!--整合mybatis框架-->
<!--配置连接池 c3p0-->
<bean id="DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
<property name="driverClass" value="com.mysql.cj.jdbc.Driver."></property>
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/ssm?serverTimezone=UTC"></property>
<property name="user" value="root"></property>
<property name="password" value="lfno11"></property>
</bean>
<!--配置Sqlsession工厂-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="DataSource"></property>
</bean>
<!--配置AccountDao接口所在包-->
<bean id="mapperScaner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.java.dao"></property>
</bean>
我的错误是未导入spring jdbc的依赖
参考:
https://www.jianshu.com/p/961c8917c69c