Today, the framework wants to use annotation to implement section function, and the result is error type referred to is not an annotation type:RedisCache
The code is as follows:
Note:
the
@Target({ ElementType.METHOD })
@Retention( RetentionPolicy.RUNTIME )
@Inherited
@Documented
public @interface RedisCache {
public String key() default “”;
public long TTL() default 0L;
}
Section:
@Around(“@annotation(redisCache)”)
public void redisCache(ProceedingJoinPoint joinPoint,RedisCache redisCache){
String targetName = joinPoint.getTarget ().getClass().getName();
String methodName = joinPoint.getSignature ().getName();
Object[] arguments = joinPoint.getArgs ();
Object result = null;
String cacheKey = getCacheKey(targetName, methodName, arguments);
System.out.println (“hahaha” + cachekey);
}
the original annotation must be passed in as a parameter, and the red part must be the same.