这个切入点的格式问题是什么?
@Around("execution(* @myPackage.SafetyCritical.*(*))&& @annotation(deny)")
.我忘了添加:异常(exception)是“切入点格式不正确:需要“名称模式”(&& 之前的最后一个右括号)
举个例子,切入点应该与此类一起使用:
@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");
}
}
最佳答案
编辑:
我认为您正在寻找的切入点表达式更像是这样的:
@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有一些使用它来表示接受任意数量的参数的示例。
此外,我大胆猜测在包名称前面包含“@”符号是 Not Acceptable 。您应该将其删除。
关于java - 切入点格式不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8474183/