- 背景
-
自定义注解 + AOP实现具体注解功能
-
报错信息:
Caused by:java.lang.IllegalArgumentException: error Type referred to is not an annotation type: xxx(xxx是注解名称)
-
语法用法
within(@com.example.gongjin28.controller.AnnotationController *)
匹配com.example.gongjin28.controller包及子包下带有@AnnotationController注解的任何类的任何方法
-
- 添加注解的代码
@Controller @RequestMapping("/controller") public class AnnotationController { @RequestMapping("/annotation") @RequestLimit(count = 300, time = 60) public void annotationTest() { } }
- 切面代码
@Component @Aspect public class RequestLimitTest { @Before("within(@com.example.gongjin28.controller.AnnotationController *)&&@annotation(requestLimit)") public void requestLimit(final JoinPoint joinPoint, RequestLimit requestLimit) { } }
- 问题解决 1、注解的引用名称不一样2、语法问题(包括但不限于以下语法问题,包括路径错误等)
3、缓存问题
3.1、清理一下idea缓存
3.2、再maven clean一下
3.3、搞定



