public class DefaultTransactionAttribute extends DefaultTransactionDefinition implements TransactionAttribute {
public boolean rollbackOn(Throwable ex) {
return ex instanceof RuntimeException || ex instanceof Error;
}
}
org.springframework.transaction.UnexpectedRollbackException: Transaction rolled back because it has been marked as rollback-only at
org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:870)at
org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:707) at
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:385) at
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:118) at
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) at
com.pphh.demo.service.UserAService$$EnhancerBySpringCGLIB$$73a6d5aa.insertUser(<generated>) ~[classes/:na]
public class UserBService {
@Transactional(propagation = Propagation.NEW)
public void insertUser(UserInfoDTO user) throws Exception {
// 保存用户记录B
userInfoDAO.insert(user);
throw new RuntimeException("Oh, an error happened");
}
}
<body><h1>HTTP Status 406 – Not Acceptable</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Description</b> The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.</p><hr class="line" /><h3>Apache Tomcat/8.5.37</h3></body>
后端日志报如下HttpMediaTypeNotAcceptableException异常信息,
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation