Could not obtain transaction-synchronized Session for current thread

异常:Could not obtain transaction-synchronized Session for current thread

两种情况:
1、 新加的业务方法不在事务传播特性限定的方法名中

<tx:advice id="txAdvice" transaction-manager="transactionManager" >
      <tx:attributes>
        <tx:method name="save*" propagation="REQUIRED"/>
        <tx:method name="create*" propagation="REQUIRED"/>
        <tx:method name="insert*" propagation="REQUIRED"/>
        <tx:method name="update*" propagation="REQUIRED"/>
        <tx:method name="delete*" propagation="REQUIRED" />
        <tx:method name="select*" propagation="REQUIRED"/>
        <tx:method name="load*" propagation="REQUIRED"/>
        <tx:method name="get*" propagation="REQUIRED" />
        <tx:method name="do*" propagation="REQUIRED" />
      </tx:attributes>
    </tx:advice>


2、   新加的业务层目录在配置事务切面的时候没有扫描到

 <aop:config  expose-proxy="true">
        <aop:pointcut id="txPointcut" expression="execution(* com..service.spring.*.* (..))"/>
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" order="500"/>
    </aop:config>

猜你喜欢

转载自weilikk.iteye.com/blog/2317319
今日推荐