参考: https://www.cnblogs.com/Geyoung/p/6927905.html

@Aspect
@Component
public class TimeAspect {
//通过这种方法可以拿到对象中所有的方法,对象
@Around("execution(* com.imooc.web.controller.UserController.*(..))")
public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable { System.out.println("time aspect start"); Object[] args = pjp.getArgs();
for (Object arg : args) {
System.out.println("arg is "+arg);
} long start = new Date().getTime(); Object object = pjp.proceed(); System.out.println("time aspect 耗时:"+ (new Date().getTime() - start)); System.out.println("time aspect end"); return object;
} }
05-11 05:20