使用注解实现声明式事务处理

来源:互联网 发布:千兆路由器和千兆端口 编辑:程序博客网 时间:2024/06/01 10:25

applicationContext-mybatis.xml配置信息:

<!-- 配置支持使用注解@Transactional配置事务 --><bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><tx:annotation-driven transaction-manager="txManager"></tx:annotation-driven>

service层:

@Transactional//为该类所有方法统一添加事务处理(如果某方法需要采用不同的事务规则,也可以在方法上添加此注解)@Service("userService")//用于标注业务层public class UserServiceImpl implements UserService {


原创粉丝点击