Spring AOP: Getting parameters of the pointcut annotation

前端 未结 2 2077
北海茫月
北海茫月 2020-12-14 02:43

Consider I have defined the following aspect:

@Aspect
public class SampleAspect {

    @Around(value=\"@annotation(sample.SampleAnnotation)\")
    public Obj         


        
2条回答
  •  轮回少年
    2020-12-14 02:56

    Change the advice signature to

    @Around(value="@annotation(sampleAnnotation)")
    public Object display(ProceedingJoinPoint joinPoint, SampleAnnotation sampleAnnotation ) throws Throwable {
        // ...
    }
    

    and you will have access to the value in the annotation.

    See docs for more info.

提交回复
热议问题