aspectj 获取 连接点 方法!

public static Method getMethod(JoinPoint joinPoint) {
        Method method = null;
        String name = joinPoint.getSignature().getName();

        try {
        // 这才是 正统!
            MethodSignature signature = (MethodSignature) joinPoint.getSignature();
            Class[] types = signature.getParameterTypes();

            joinPoint.getSignature();
            method = joinPoint.getTarget().
                    getClass().getMethod(name,types);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        }
        return method;
    }

 多个连接点--

@Before("@annotation(cloud.cjy.travel.module.common.annotation.CjyAspect) || within(@cloud.cjy.travel.module.common.annotation.CjyAspect *)")

或者:

private static MethodSignature getMethodSignature(JoinPoint joinPoint) {
Signature signature = joinPoint.getSignature();
return (MethodSignature) signature;
}



public
static Method getMethod(JoinPoint joinPoint) { MethodSignature methodSignature = getMethodSignature(joinPoint); return methodSignature.getMethod(); }
原文地址:https://www.cnblogs.com/whm-blog/p/11098807.html