自己写的时候发现
Topic source谢谢 @SNH48-刘慈欣 我正想问后面那个xxx为啥是metricTime 而不是MetricTime
所以这里的xxx就是a啦
@Around("@annotation(a)")public Object metric(ProceedingJoinPoint joinPoint, MetricTime a) throws Throwable {
那请问
public Object metric(ProceedingJoinPoint joinPoint, MetricTime metricTime) throws Throwable {
这里metric里面的参数是怎么觉得定的呢?
消息
- 1
SNH48-刘慈欣
@Around("@annotation(xxx)")
,这个xxx必须改为方法签名里annotation类里的引用参数名一模一样不然会报错;而且改成不是metricTime,也照样会在有@MetricTime
的方法前后执行,是不是说明MetricAspect这样的Aspect,在什么地方织入并不取决于@Around("@annotation(xxx)")
括号里的xxx,而是取决于它方法第二个参数的引用类型?其次还发现
@Before("@annotation(xxx)")
也可以,只要删掉方法里的ProceedingJoinPoint参数并改为void返回类型就可以了。