@Target({ElementType.METHOD})@Retention(RetentionPolicy.RUNTIME)public @interface XAudit {}
切面
@Component@Aspect@Order(-1)public class XAuditAspect {@Around(value = "@annotation(xAudit)")public Object postAuditEvent(ProceedingJoinPoint joinPoint, XAudit xAudit) throws Throwable {Object result = null;try {result = joinPoint.proceed();} catch (Throwable throwable) {throwable.printStackTrace();throw new DAOException(609,throwable.getMessage());}//audit processing logicreturn result;}}
开启aop
xml 方式
springboot @EnableAspectJAutoProxy // aop的启动
