1.定义注解
@Target(ElementType.METHOD)//作用位置
@Retention(RetentionPolicy.RUNTIME)//什么时候有效·
public @interface CacheFind {
String key(); //要求·用户自己制指定
int seconds() default -1;//设定超时时间
}
2.使用注解
在方法上使用这个注解
@Override
@CacheFind(key="ITEN_CAT_PARENTID")
public List<EasyUITree> findItemCatList(Long parentId)
2.获取注解标识的方法
通过joinpoint获取注解中的key
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
//1.获取目标对象类型
Class targetClass = joinPoint.getTarget().getClass();
//2.获取方法
String name = joinPoint.getSignature(