1.service层事务注解
@Transactional(isolation = Isolation.REPEATABLE_READ,propagation = Propagation.REQUIRED)
2.springconfig 配置事务管理器和启动事务注解
<!--事务管理器--> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!--启用事务注解--> <tx:annotation-driven transaction-manager="txManager"></tx:annotation-driven>