annotation
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Delete {
String key() default "";
}
切面(aspect)
@Aspect
@Component
public class Aspect {
@After(value = "@annotation(d)", argNames = "d")
public void after(Delete d) {
System.out.println(d.key());
System.out.println("after");
}
}
使用
@Service
public class UserService {
@Delete(key = "abc")
public void update() {
System.out.println("update user");
}
}