1.@interface自定义注解自动继承了java.lang.annotation.Annotation接口,由编译程序自动完成其他细节。
2.在定义注解时,不能继承其他的注解或接口。
3.使用@interface来声明一个注解。
@Target({ ElementType.TYPE, ElementType.METHOD,ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
public @interface ReadAspect {
String value();
}
2.写一个类自定义一个方法
@Aspect
@Component
public class ServiceIsReadAspect {
@Before("@annotation(com.chinaeducloud.ss.aspect.ReadAspect)") //扫描注解的位置
public void recordTimeLog(JoinPoint joinPoint) {
一些逻辑.............
}
}
最后作用在Controller的方法上
结束!!!!!!!
本文参考如下博客,然后按照个人喜欢的方式改造一下例子,加深理解,感谢分享.
注解的使用和解释参考:https://blog.csdn.net/javazejian/article/details/71860633
https://blog.csdn.net/zhangbeizhen18/article/details/87885441/



