<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> @Service @Transactional public class ProductService { @Autowired private ProductDAO productDAO; public void saveProduct(Product product) { productDAO.save(product); } } <bean id="transactionAspect" class="org.springframework.transaction.aspectj.AnnotationTransactionAspect"> <property name="transactionManager" ref="transactionManager"/> </bean> <aop:config> <aop:aspect id="transactionalAspect" ref="transactionAspect"> <aop:pointcut id="transactionPointcut" expression="execution(* com.example.service.*.*(..))"/> <aop:advisor advice-ref="transactionAdvice" pointcut-ref="transactionPointcut"/> </aop:aspect> </aop:config>


上一篇:
下一篇:
切换中文