我需要一个 Spring AOP 切入点解释 [英] I need a Spring AOP pointcut explanation
本文介绍了我需要一个 Spring AOP 切入点解释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我见过两种切入点模式的变体:
I have seen two variations of pointcut patterns:
这个
execution(* some.package.*.*(..))
还有这个
execution(* some.package.* *(..))
最后两个 * 之间的点(或没有点)是什么意思?
What is the meaning of the dot (or of it absence) between the last two *'s?
推荐答案
这个 附录 定义了切入点表达式语言的语法.对于执行表达式,规则如下:
This appendix defines grammar of the pointcut expression langauge. For the execution expression the rule is the following:
execution(MethodPattern)
哪里
MethodPattern =
[ModifiersPattern] TypePattern
[TypePattern . ] IdPattern (TypePattern | ".." , ... )
[ throws ThrowsPattern ]
这意味着如果你在("之前有3个表达式(用空格分隔),那么第一个是修饰符,第二个是类,第三个是方法名.但是如果你在("之前有2个表达式,那么第一个会是类,第二个是方法名.
That means that if you have 3 expressions (separated by space) before "(", then the first is modifier, second is class and third is method name. But if you have 2 expressions before "(", then first will be class and second will be method name.
这篇关于我需要一个 Spring AOP 切入点解释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文