这个切入点的格式问题是什么?
@Around("execution(* @myPackage.SafetyCritical.*(*))&& @annotation(deny)").i忘记添加:异常是“切入点格式不正确:需要'name pattern‘(&&之前的最后一个右括号)
例如,切入点应该与这个类一起工作:
@SafetyCritical
public class SecureClass
{
public SecureClass(){
}
@Deny
public void isNotAllowed(){
System.out.println("This should not happen");
}
@Allow
public void isAllowed(){
System.out.println("Allowed");
}
}发布于 2011-12-12 20:20:22
编辑:
我认为你正在寻找的切入点表达式应该更像这样:
@Around("@target(myPackage.SafetyCritical) && @annotation(denyPackage.Deny)")@target指示器用于匹配使用给定注释标记的类,并且@annotation指示器将过滤到使用denyPackage.Deny注释注释的方法。
再说一次,浏览一下Spring Documentation regarding AspectJ support会有所帮助。
原创:
要匹配任意数量的参数,传递给execution切入点指示器的参数定义应该是“..”
@Around("execution(* myPackage.SafetyCritical.*(..)) && @annotation(deny)")Spring documentation有一些使用它来表示接受任意数量的参数的示例。
另外,我敢说在你的包名前面有“@”符号是不能接受的。您应该将其删除。
发布于 2011-12-12 20:38:55
我使用了这样的切入点定义来匹配带注释的方法:
@Around("execution(@myPackage.SafetyCritical * *(..)) && @annotation(deny)")@annotation(deny)的最后一部分(就像您已经知道的一样,但有些人可能不知道)是将注释绑定到名为"deny“的通知方法参数。
编辑:根据您的更新,我不知道SafetyCritical是类上的注释。我想这应该是target()的目标:
@Around("execution(* *(..)) && @target(myPackage.SafetyCritical) && @annotation(deny)")https://stackoverflow.com/questions/8474183
复制相似问题