2 u010370084 u010370084 于 2016.03.22 10:26 提问

求助spring事务异常,报错报了昨天一天了55555,在线等啊

就是一直都报这个错,昨天一天都没解决,感觉是确实一个方法,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 .

4个回答

wangkang80
wangkang80   2016.03.22 15:08
已采纳

关于spring事务的详细配置,可参考:http://git.oschina.net/wangkang/llsfw

希望能够帮到你.

enpterexpress
enpterexpress   2016.03.22 10:31
u010370084
u010370084 回复有_道_是: ?你这个是代理的问题吧,缺包,我这个是没那个方法,但是我jar包都放了啊![图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/5.gif)[图片说明](http://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/001/face/5.gif)
一年多之前 回复
u010370084
u010370084   2016.03.22 10:49

不是那个包的问题,我加了还是不行,还是报相同的错误,,,5555

bigdata_ALu
bigdata_ALu   2017.10.22 17:07

在吗?这个问题你解决了没,我的也是这种错误

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!