Springboot基于注解的AOP操作

注解类

package com.example.springaop.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * @module
 * @author:DUOLUONIANDAI
 * @DATA:2024/01/06
 * @Title:
 */

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface AnnTest {
   
    String id() default "";
    String val() default "";
}

切面、切点

package com.example.springaop.aspect;

import com.example.springaop.annotation.AnnTest;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component

你可能感兴趣的:(Springboot,java实践,java,spring,boot,后端,java)