aop使用自定义注解报错 cannot resolve symbol

清疚 2024-02-05 11:55 24阅读 0赞

aop使用自定义注解报错 cannot resolve symbol ‘*‘,自定义一个注解 AuthTest,在aop场景下使用:@annotation(AuthTest)结果自定义注解报红。

错误写法:

  1. @Before("execution(* com.zhh.demo.controller.*.*(..)) && @annotation(AuthTest)")
  2. public void interceptor(JoinPoint point) {
  3. System.out.println("前置通知。。。");
  4. }

正确写法:

  1. @Before("execution(* com.zhh.demo.controller.*.*(..)) && @annotation(com.zhh.demo.common.annotation.AuthTest)")
  2. public void interceptor(JoinPoint point) {
  3. System.out.println("前置通知。。。");
  4. }

原因:如果自定义注解和aop类在同一个包下,@annotation中就可以只写注解名称,否则注解里面需要写全路径,例如:@annotation(“注解全路径”)。

发表评论

表情:
评论列表 (有 0 条评论,24人围观)

还没有评论,来说两句吧...

相关阅读