Spring 当在@Transactional 注释中指定回滚检查异常时,是否回滚运行时异常

Does Spring rollback on Runtime Exception when rollback for checked exception is specified in @Transactional annotation

在 class 上定义了以下 @Transactional 注释。

@Transactional(rollbackFor = CheckedException.class)

Spring 是否仍会在抛出未检查 (Runtime) 异常以及 CheckedException.class 时回滚?或者给出上面的注释,它会回滚 only 对于列出的异常,即在这种情况下 CheckedException.class 吗?

任何运行时异常都会导致回滚,无论你是否在 rollbackFor 中提到检查异常。