我已经编写了以下切入点,但它给出了运行时错误(线程“main”java.lang.StackOverflowError 中的异常)
切入点 traceAttribs():(get(* *));
我从您的问题中了解到的是,您需要创建一个实时了解您的方法参数的方面。
Mkyong 的页面中有一个有用的简单示例,您可能需要第 8 点。
如果你想在你的方面获得一个方法名称和参数,你可以这样写:
@Aspect
public class LoggingAspect {
@Around("execution(* com.your.package.YourClass.yourMethodAround(..))")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
System.out.println("Your method: " + joinPoint.getSignature().getName());
System.out.println("and method arguments: " + Arrays.toString(joinPoint.getArgs()));
System.out.println("Your method will be executed. ");
joinPoint.proceed(); //continue on the intercepted method
System.out.println("Ended execution");
}
}
希望有所帮助