接口方法上的自定义注解失效

现状:
mybatis 上接口的自定注解能生效…
接口方法上的自定义注解失效…
但是@Transactional在接口方法上却可以使用…
目前方案:
还是在切面逻辑里面写表达式拦整个接口吧

相关信息

Spring recommends that you only annotate concrete classes (and methods of concrete classes) with the @Transactional annotation, as opposed to annotating interfaces. You certainly can place the @Transactional annotation on an interface (or an interface method), but this works only as you would expect it to if you are using interface-based proxies. The fact that Java annotations are not inherited from interfaces means that if you are using class-based proxies ( proxy-target-class=“true”) or the weaving-based aspect ( mode=“aspectj”), then the transaction settings are not recognized by the proxying and weaving infrastructure, and the object will not be wrapped in a transactional proxy, which would be decidedly bad.
Spring 建议您仅使用 @Transactional 注释来注释具体类(以及具体类的方法),而不是注释接口。您当然可以将 @Transactional 注释放在接口(或接口方法)上,但这仅在您使用基于接口的代理时按照您期望的方式工作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值