1. @Target({ElementType.METHOD})
    2. @Retention(RetentionPolicy.RUNTIME)
    3. public @interface XAudit {
    4. }

    切面

    1. @Component
    2. @Aspect
    3. @Order(-1)
    4. public class XAuditAspect {
    5. @Around(value = "@annotation(xAudit)")
    6. public Object postAuditEvent(ProceedingJoinPoint joinPoint, XAudit xAudit) throws Throwable {
    7. Object result = null;
    8. try {
    9. result = joinPoint.proceed();
    10. } catch (Throwable throwable) {
    11. throwable.printStackTrace();
    12. throw new DAOException(609,throwable.getMessage());
    13. }
    14. //audit processing logic
    15. return result;
    16. }
    17. }

    开启aop
    xml 方式
    springboot @EnableAspectJAutoProxy // aop的启动