spring 怎么才能进入注解相关的反射类代码里,我想看看注解代码相关的反射类里逻辑(不是看注解类,)
从容器启动开始看吧,不同的组件,处理方式不相同
package com.gray.interceptor;
import java.lang.reflect.Method;
import org.aspectj.lang.JoinPoint;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.gray.annotation.Log;
@Aspect
@Component
public class LogInterceptor {
private final Logger logger = LoggerFactory.getLogger(LogInterceptor.class);
@Pointcut("@annotation(com.gray.annotation.Log)")
public void controllerAspect() {
}
@Before("controllerAspect()")
public void before(JoinPoint joinPoint){
logger.info(getOper(joinPoint));
}
private String getOper(JoinPoint joinPoint) {
// 获取当前注解类
jp.getTarget().getClass();
}