@AfterReturning(切入点)vs @AfterReturning(值)

时间:2018-02-23 20:00:15

标签: java spring spring-aop

"...".r.findAllIn@AfterReturning(pointcut)

之间有何区别?
@AfterReturning(value)

上述方法会产生@AfterReturning(pointcut = "execution(* my.java.model.Triangle.myTest*(param))", returning = "returnedString", argNames = "param,returnedString") public void afterReturningAdvice(String param, String returnedString) { System.out.println("Executing after function advice that accepts the input " + param + " and returns " + returnedString); }

替换上面的代码后,它工作正常
Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: error at ::0 name binding only allowed in target, this, and args pcds

值与切入点

之间有什么区别?

1 个答案:

答案 0 :(得分:0)

在切入点中,您可以绑定方法参数this()target()@annotation()。这适用于所有建议类型。

@AfterReturning中,您还可以绑定返回值并在@AfterThrowing中抛出异常。

方法参数和返回值不要互相误解。