就是一直都报这个错,昨天一天都没解决,感觉是确实一个方法,NoSuchMethodError:org.springframework.jdbc.datasource.DataSourceTransactionManager.determineTimeout,我导入源码看不到这个方法,只有一个调用它的参数,,,求大牛或者神牛帮帮忙,拜托了。。。。困扰了一天啊,,,,!!!整个人都不好了,在线等!!
报错信息:
Exception in thread "main" org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.lang.NoSuchMethodError: org.springframework.jdbc.datasource.DataSourceTransactionManager.determineTimeout(Lorg/springframework/transaction/TransactionDefinition;)I
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:242)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:283)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:225)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at sun.proxy.$Proxy12.buyOneBook(Unknown Source)
at org.Tran.Service.Imp.BuySomeBookImp.buySomeBook(BuySomeBookImp.java:17)
at org.Tran.Test.Main.main(Main.java:16)
Caused by: java.lang.NoSuchMethodError: org.springframework.jdbc.datasource.DataSourceTransactionManager.determineTimeout(Lorg/springframework/transaction/TransactionDefinition;)I
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:229)
... 10 more
我的springConf.xml配置如下
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:annotation-config/>
<context:component-scan base-package="org.Tran.*"/>
<context:property-placeholder location="classpath:org/Tran/db.properties"/>
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driver}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:org/Tran/xml/MybatisConf.xml"/>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="bookMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="org.Tran.DAO.BookDAO"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory"/>
</bean>
<!--1. 事务配置 -->
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="nestedTransactionAllowed" value="true"/>
</bean>
<!-- 启用事务注解! --><!--
<tx:annotation-driven transaction-manager="transactionManager"/>
-->
<!--2.配置事务属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="*"/>
</tx:attributes>
</tx:advice>
<!-- 3.配置事务切入点 -->
<aop:config>
<aop:pointcut expression="execution(* org.Tran.Service.BuyBookInterface.*(..))"
id="txPointCut"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/>
</aop:config>
</beans>
测试代码:
ApplicationContext ctx = new ClassPathXmlApplicationContext("org/Tran/xml/SpringConf.xml");
// BookServiceInterface bookService=ctx.getBean(BookServiceInterface.class);
BuySomeBookInterface buybook=ctx.getBean(BuySomeBookInterface.class);
buybook.buySomeBook("Jack", Arrays.asList("0001","0002"));
下面是我的jar包
我的数据库是mysql,表类型也是正常默认的innodb .