在使用Aspectj獲取方法注解信息的時候,可以使用下面的代碼片段:
/** * Get value of annotated method parameter */ private <T extends Annotation> T getMethodAnnotation(ProceedingJoinPoint joinPoint, Class<T> clazz) { MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); Method method = methodSignature.getMethod(); return method.getAnnotation(clazz); }