1
import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) public @interface MyAnnotation { String descraption() default ""; }
2
@Aspect @Component public class AnnotationImplement { @Pointcut("@annotation(com.aop.MyAnnotation)") public void annotation(){ //任何代码都不会执行 } @Around("annotation()") public void afterPoint(ProceedingJoinPoint point){ System.out.println(point.getTarget().getClass().getName()); Object[] obj = point.getArgs(); for (int i = 0; i < obj.length; i++) { System.out.println(obj.toString()); } } }
3
时间: 2024-10-01 07:00:39