发布时间:2024-05-31 14:01
常见事务失效原因:
1.内部调用(常见于同一个service引用了本service的方法,且最开始的方法没有打上注解)
2.没有指定监听的Exception(常见于抛出的异常非RuntimeException及其子类)
3.异常被方法内部try catch掉了,未向外抛出
4.方法不是public的
而我出现的场景并不在上述的原因列表中,且伴随着@Async注解也失效了,其实是由于Spring 的Aop失效导致的,并可观测出,在controller层拿到的springboot自动注入的service对象并非代理对象。
此问题通常还伴随着程序启动时,会输出这类的日志:
[com.landray.ldingbridge3.agent.core.service.impl.RoleMenuRelationServiceImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.804 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'rolePermRelationMapper' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.805 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'rolePermRelationMapper' of type [com.sun.proxy.$Proxy111] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.806 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'rolePermRelationServiceImpl' of type [com.landray.ldingbridge3.agent.core.service.impl.RolePermRelationServiceImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.810 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'userRoleRelationMapper' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.811 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'userRoleRelationMapper' of type [com.sun.proxy.$Proxy112] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.813 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'userRoleRelationServiceImpl' of type [com.landray.ldingbridge3.agent.core.service.impl.UserRoleRelationServiceImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.818 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'userInfoMapper' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.819 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'userInfoMapper' of type [com.sun.proxy.$Proxy113] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.826 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'deptInfoMapper' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.827 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'deptInfoMapper' of type [com.sun.proxy.$Proxy114] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.831 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'deptUserRelationMapper' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
traceId:[],tenantId:[] 2022-01-04 15:02:10.832 INFO 24056 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'deptUserRelationMapper' of type [com.sun.proxy.$Proxy115] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
表示springboot在提醒开发者,这些类并未被spring所包装,之前一直忽视了这个问题,知道出现事务失效的问题才来寻找原因,最后定位到这里,发现是由于shiro导致的。
最后解决:
解析:由于shiro的这个realm需要在程序一启动的时候马上实例化,而这时spring的bean处理器还未对service对象包装成代理对象,所有就将未代理的原始对象进行了注入,而导致AOP的失效
MyBatis注解开发-@Insert和@InsertProvider的使用
zookeeper dubbo php,ZooKeeper分布式专题与Dubbo微服务入门 (完整版)
武汉,是你来明媚我的忧伤了么?_RWERWERWE_96921_新浪博客
复旦大学首届达观数据奖学金颁奖仪式圆满落幕,达观CEO陈运文博士与学院党委书记王新为获奖同学颁奖
进大厂必备的Java八股文大全(2022最强精简易懂版,八股文中的八股文)备战秋招,赶快转发收藏起来吧~
(Windbg调试二)C++ delete指针后依然可以访问的问题
【MQTT从入门到提高系列 | 03】一文掌握MQTT3.1.1协议框架
【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘