捕捉异常之后手动标记回滚事务
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
没有嵌套事务,还是报Transaction rolled back because it has been marked as rollback-only异常错误
查看错误堆栈,service调用的方法外层还套有一层事务,方法内部手动标记回滚,没有抛出异常,外部方法还是会提交事务导致报错
JDK动态代理导致的
但是Spring2.x默认使用cglib动态代理,更改配置spring.aop.proxy-target-class=true也不起作用
最后对比过往项目发现整合shiro时引入包
<dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring-boot-starter</artifactId> </dependency>
改用shiro-spring包可以解决
<dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId> </dependency>