@Target(ElementType.METHOD) 定义范围 解释:
@Retention(RetentionPolicy.RUNTIME ) 解释:
package mms.shop.launcher.test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD) //定义注解@CheckAge的使用范围
@Retention(RetentionPolicy.RUNTIME )
public @interface CheckAge {
}
切面
package mms.shop.launcher.test;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
@Component