1、service层方法抛出自定义异常(继承自Exception),使用声明式事务@Transaction,不回滚
根据官方文档所描述的,声明式事务默认仅支持runtime, unchecked exceptions,可将自定义异常继承自RuntimeException 或 @Transactional(rollbackFor=Exception.class)
In its default configuration, the Spring Framework’s transaction infrastructure code only marks a transaction for rollback in the case of runtime, unchecked exceptions; that is, when the thrown exception is an instance or subclass of RuntimeException. ( Errors will also - by default - result in a rollback). Checked exceptions that are thrown from a transactional method do not result in rollback in the default configuration.