博客
关于我
spring之使用事务(二)
阅读量:479 次
发布时间:2019-03-06

本文共 307 字,大约阅读时间需要 1 分钟。

接上一节:https://www.cnblogs.com/xiximayou/p/12167894.html

利用事务来处理上述问题。

在applicationContext.xml中配置事务管理器:

启用事务注解:

然后在purchase方法上加上事务注解:

@Transactional    @Override    public void purchase(String username, String isbn)

此时,我们在运行testBookShopService方法,发现当余额不足时,库存并不会再减少了。

你可能感兴趣的文章
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>