Spring中解决Aop 事务嵌套回滚问题
来源:互联网 发布:淘宝卖家购物车加购数 编辑:程序博客网 时间:2024/05/21 11:07
今天被坑了,这是部分代码
//组装操作日志 这个增强里面后面的两个参数必须一样,为函数执行后返回的结果
@AfterReturning(value="addLog()",argNames="rtv",returning="rtv")
public void packLogs(JoinPoint joinPoint,Object rtv) throws Throwable {
//获取方法名
String methodName=joinPoint.getSignature().getName();
//获取操作内容
String opt_content=pakeOptionContent(joinPoint.getArgs(),methodName,rtv);
logger.debug(opt_content);
//组装操作sysLog
sysLog=new SysLog();
ipAddr=InetAddress.getLocalHost();
sysLog.setLog_ip(ipAddr.getHostAddress());
sysLog.setOpt_desc(opt_content);
sysLog.setOpt_time(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
sysLog.setOpt_user("cuibruce");
sysLogService.saveLog(sysLog);
结果报最后这个syslogService.save的时候出错 说事务已经是rollbackonly了 。查了好多资料说则个事务嵌套 默认使用的是一个事务 ,不会创建新的事务,
但是我把事务标记为required_new也是不行啊 ,最后在application.xml中事务管理器中添加了如下的代码就好了 对事务传播有了一个更新的认识了、
<!--配置事务-->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
<property name="globalRollbackOnParticipationFailure" value="false" />
</bean>
<jpa:repositories base-package="main" entity-manager-factory-ref="entityManagerFactory"></jpa:repositories>
- Spring中解决Aop 事务嵌套回滚问题
- spring aop事务配置,事务回滚
- spring事务回滚问题
- spring事务回滚问题
- 简单的Spring事务嵌套与事务回滚
- Spring中发生异常的事务回滚问题
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚
- Spring AOP声明式事务异常回滚 若干法则
- Spring AOP声明式事务异常回滚
- Stock Value
- 获取drawRect绘图后的截图
- caffe安装,编译(包括CUDA和cuDNN的安装),并训练,测试自己的数据(caffe使用教程)
- 【leetcode】108. Convert Sorted Array to Binary Search Tree
- 网络编程序列2——C#TCP服务端代码实现二
- Spring中解决Aop 事务嵌套回滚问题
- flume源码分析三:flume组件的启动,关闭和监控
- 纪念成为博客专家 - 碎碎念
- E/BaseJsonHttpCallable: Binary XML file line #7: Error inflating class android.widget.ListView
- play框架使用起来(18)
- 关于 supervisor 的 autorestart 为 unexpected
- C++变长参数
- 玩转Linux - 常用的命令和操作
- shell awk 详解