当前位置:网站首页>service事物失效如何获取代理事物
service事物失效如何获取代理事物
2022-07-29 17:21:00 【垂钓的小鱼1】
在我们项目中有事物失效的情况
在一个没用开启事物的方法中调用另外一个开启了事物的方法,在调用createVoucherOrder方法的时候是通过this去调用的,并不是通过代理对象调用,所以事物失效,此时我们应该是通过代理对象来调用

该如何做呢
添加maven依赖
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
在启动类里面添加一个注解@EnableAspectJAutoProxy(exposeProxy = true),开启adpectj代理
@EnableAspectJAutoProxy(exposeProxy = true)
@MapperScan("com.hmdp.mapper")
@SpringBootApplication
public class HmDianPingApplication {
public static void main(String[] args) {
SpringApplication.run(HmDianPingApplication.class, args);
}
}


如此事物生效了
边栏推荐
猜你喜欢
随机推荐
Frame双向通信插件FrameDataTrans
"Hardcore" labelme shows the label in the picture
HER2-2-ME-BSANPs单抗特异性的2-甲氧基雌二醇白蛋白纳米粒的研究与制备
TensorFlow Serving high-performance machine learning model of service system
提高编程效力的5大VS Code Extensions
Texture 】 【 terrain 】 【 virtual virtual terrain texture technology is introduced
go defer panic recover入门
UNIX Environment Advanced Programming Chapter 3
Google Earth Engine APP——一键在线查看全球1984-至今年的影像同时加载一个影像分析
STC8h1k28六个基本实验
清道夫受体-A靶向脂肪酸修饰白蛋白纳米粒/银耳多糖修饰白蛋白微球的制备
[Network knowledge] Routing OSPF
Fast Reed-Solomon Interactive Oracle Proofs of Proximity学习笔记
虚拟偶像的歌声原来是这样生成的!
接口内容01文档:postman学习路线
学会 arthas,让你 3 年经验掌握 5 年功力!
js彩色树叶飘落动画js特效
回帖免责声明-转载
Greedy (1) interval complete coverage problem
Route ISIS









