@RestController
public class AController {
@Autowired
AService aService;
// 回滚
@GetMapping("direct")
public void direct() {
aService.testTransactional();
}
// 不回滚
@GetMapping("indirect")
public void indirect() {
aService.testTransactionalIndirect();
}
// 不回滚
@GetMapping("nonPublic")
public void nonPublic() {
aService.testTransactionalNonPublic();
}
// 不回滚
@GetMapping("catchException")
public void catchException() {
aService.testTransactionalCatchException();
}
// 不回滚
@GetMapping("sqlException")
public void sqlException() throws SQLException {
aService.testTransactionalSQLException();
}
// 回滚
@GetMapping("sqlExceptionWithRollbackfor")
public void sqlExceptionWithRollbackfor() throws SQLException {
aService.test
@Transactional 错误使用的几种场景
最新推荐文章于 2023-08-10 10:09:25 发布