现状:
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 注释放在接口(或接口方法)上,但这仅在您使用基于接口的代理时按照您期望的方式工作。