public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Method realMethod = joinPoint.getTarget().getClass().getDeclaredMethod(signature.getName(), method.getParameterTypes());
XxxxAnnotation xxxxAnnotation= realMethod.getDeclaredAnnotation(XxxxAnnotation.class);
解决方法:
- 直接用 method.getDeclaredAnnotation(XxxxAnnotation.class) 获取注解为null
- 需要用方法的代理原始目标类取获取注解 realMethod.getDeclaredAnnotation(XxxxAnnotation.class)