Spring aop,未绑定的切入点参数

时间:2017-07-04 17:21:41

标签: spring aop

我得到这个错误,我真的不明白:

unbound pointcut parameter auditable

以下代码:

@Aspect
public class TestAspect {

    @Before(value = "@annotation(Action)")
    public void audit(JoinPoint joinPoint, Action auditable) {
        System.out.println(auditable);
    }
}

 @Action(ActionType.FAST)
    public static void resolveFast(String name){
        System.out.println(name);
    }

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Action {

    ActionType value();
    boolean withArgs() default false;
}

public enum ActionType {
    FAST, SLOW
}

问题发生在@Before注释上,这些是我在aop中的第一步...

3 个答案:

答案 0 :(得分:3)

在此声明中:

A-E

您应将$(document).scroll(function () { if ($(window).scrollTop() > 450) { //$(".header").css("margin-top", "0"); <- This works perfectly but its not animated $(".header").css("background-image", "url('/images/header.jpg')"); $(".header").animate({'margin-top': 0}, "slow"); } else if ($(window).scrollTop() < 450) { // $(".header").css("margin-top", "40");<- This works perfectly but its not animated $(".header").animate({'margin-top': 40}, "slow"); $(".header").css("background-image", "none"); } }); 替换为 @Before(value = "@annotation(Action)")

答案 1 :(得分:1)

尝试参考代码

@Before("execution(public String com.captaindebug.audit.controller.*Controller.*(..)) && @annotation(auditAnnotation)")
    public void auditScreen(JoinPoint joinPoint,Audit auditAnnotation) {...}

答案 2 :(得分:0)

像这样更改代码:

    @Before(value = "@annotation(auditable)")
    public void audit(JoinPoint joinPoint, Action auditable) {
        System.out.println(auditable);
    }

您看到了不同吗?

对,@annotation的参数应该为 auditable !!!

好吧,现在,我花了将近2个小时来调试...

就是这个。我感到很浪费生命,但我真的希望能挽救您的生命……

我仍然感到难过...