@Log 注解
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Log {
String value() default "";
}
LogAdvice
@Aspect
@Component
public class LogAdvice {
@Pointcut("@within(com.xxx.annotation.Log) || @annotation(com.xxx.annotation.Log)")
private void advice() {
}
@Before("advice()")
public void doBefore(JoinPoint jp) {
String methodInfo = getMethodInfo(jp);
System.out.println(methodInfo);
}
// ...
}
麻烦点个赞呗~