aop使用自定义注解报错 cannot resolve symbol
aop使用自定义注解报错 cannot resolve symbol ‘*‘,自定义一个注解 AuthTest,在aop场景下使用:@annotation(AuthTest)结果自定义注解报红。
错误写法:
@Before("execution(* com.zhh.demo.controller.*.*(..)) && @annotation(AuthTest)")
public void interceptor(JoinPoint point) {
System.out.println("前置通知。。。");
}
正确写法:
@Before("execution(* com.zhh.demo.controller.*.*(..)) && @annotation(com.zhh.demo.common.annotation.AuthTest)")
public void interceptor(JoinPoint point) {
System.out.println("前置通知。。。");
}
原因:如果自定义注解和aop类在同一个包下,@annotation中就可以只写注解名称,否则注解里面需要写全路径,例如:@annotation(“注解全路径”)。
还没有评论,来说两句吧...