@Around("myPointcut()")
public Integer AroundSave(ProceedingJoinPoint joinPoint) throws Throwable {
/*1、获取目标方法的参数:save(new User()),此时user对象可以获取到*/
Object[] args = joinPoint.getArgs();
System.out.println("这是joinPoint的Api开始--------------------");
System.out.println("打印目标方法参数列表args ="+ Arrays.toString(args));
/*2、可以获取到目标方法的反射对象Method*/
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
System.out.println("获取目标方法的对象名称:"+method);
/*2.1、由method反射对象获取基本信息*/
Class<?> declaringClass = method.getDeclaringClass();
String className = declaringClass.getName();
System.out.println("获取类名"+className);
System.out.println("环绕通知开始");
Integer result= (Integer) joinPoint.proceed();
System.out.println("环绕通知结束");
return result;
}
ProceedingJoinPoint joinPoint Api使用
于 2022-02-12 16:45:42 首次发布