实现背景:需要对service中各个方法进行日志记录,包括执行时间,方法用途,以及方法执行结果等。从而知道每个方法对数据库的改动以及影响。
为了实现对每个方法用途的记录,定义了一个注解,然后在注解中存放了方法的用途信息。
定义注解:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ServiceLogAnnotation {
public String value();
}
定义AOP advisor:关于@Pointcut的用法请参见这里
@Component
@Aspect
publi