【发布时间】:2017-03-29 17:20:22
【问题描述】:
项目中的所有类都在 com.aspect 包中。
主要看点:
@Aspect
public class MainAspect {
@Pointcut("within(com.aspect..*)")
public void standaloneLayer(){}
}
以帐户对象为参数的连接点的另一个方面:
@Aspect
public class AccountAspect {
@After("com.aspect.MainAspect.standaloneLayer() && args(account)")
public void pointCutForAccount(JoinPoint joinPoint, Account account){
}
}
服务层类:
@Service
public class Customer {
public void setAccountBalance(Account account) {}
}
在运行应用程序时出现以下异常:
原因:
java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
【问题讨论】:
-
通过在@AfterThrowing 注释中将值属性更改为切入点属性来修复它
标签: java spring-aop