Spring事务中处理哪些异常

1. 默认情况下处理 RuntimeException Error两种,然后回滚

	public boolean rollbackOn(Throwable ex) {
		return (ex instanceof RuntimeException || ex instanceof Error);
	}

2. 如果配置了rollback-for,那么会判断Exception是否符合配置,然后回滚

		if (this.rollbackRules != null) {
			for (RollbackRuleAttribute rule : this.rollbackRules) {
				int depth = rule.getDepth(ex);
				if (depth >= 0 && depth < deepest) {
					deepest = depth;
					winner = rule;
				}
			}
		}


猜你喜欢

转载自blog.csdn.net/u011385186/article/details/79090416