读取方面的注释属性
如何读取aspect中的注释属性值?
我希望对所有用 @Transactional(readonly=false) 注释的关节点执行我的 Around 建议。
@Around("execution(* com.mycompany.services.*.*(..)) "
+ "&& @annotation(org.springframework.transaction.annotation.Transactional)")
public Object myMethod(ProceedingJoinPoint pjp) throws Throwable {
}
How to read annotation property value in aspect?
I want my Around advice to be executed for all joint points annotated with @Transactional(readonly=false).
@Around("execution(* com.mycompany.services.*.*(..)) "
+ "&& @annotation(org.springframework.transaction.annotation.Transactional)")
public Object myMethod(ProceedingJoinPoint pjp) throws Throwable {
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在不手动处理签名的情况下完成此操作,这种方式(
argNames
用于在没有调试信息的情况下编译时保留参数名称):请参阅 7.2.4.6 建议参数
You can do it without manual processing of signature, this way (
argNames
is used to keep argument names when compiled without debug information):See 7.2.4.6 Advice parameters
你可以这样做:
注释:
拦截器:
You can do this this way:
Annotation:
Interceptor:
您必须在代码中执行此操作。例如,
但是您真的确定要扰乱事务处理吗?
you will have to do it in the code. For example
But are you really sure you want to mess with transaction handling?