Spring阶段性学习总结(十 三)重用切点表达式

即将之前的每个方法上的@before ()里大段的包名+类名+方法名做简化,定义一个@pointCut的方法,参数是之前其他注解的参数,然后在其他方法的注解参数中 调用该方法即可,

 1     @Pointcut("execution(public int SpringAopImp.CalculatorImp.add(int ,int))")
 2     public void declearExpresion(){}
 3     //前置通知在目标方法开始前执行
 4 
 5     @Before("declearExpresion()")
 6     public void beforeMethod(JoinPoint joinPoint) {
 7         String methodName = joinPoint.getSignature().getName();
 8         List<Object> args = Arrays.asList(joinPoint.getArgs());
 9         System.out.println("The Method:" + methodName + " beginWith:" + args);
10     }
原文地址:https://www.cnblogs.com/zhang188660586/p/11588735.html