本系列博客将学习开发SpringBoot,快速开发项目
SpringBoot系列 (五):SpringBoot 之Spring 事务管理 和 切面 AOP
文档结构
- SpringBoot 之事务管理@Transactional
- SpringBoot 之切面 AOP
一、 SpringBoot 之事务管理@Transactional
通过在service方法中加上@Transactional注解实现事务管理。
package com.tofree.service;
/**
* 账户Service接口
* @author tofree
*
*/
public interface AccountService {
/**
* 从A用户转账b用户钱
* @param fromUser
* @param toUser
* @param account
*/
public void transferAccounts(int fromUser,int toUser,float account);
}
实现方法:
package com.tofree.service.impl;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.springframework.stereotype.Service;
import com.tofree.dao.AccountDao;
import com.tofree.entity.Account;
import com.tofree.service.AccountService;
/**
* 帐号Service实现类
* @author