cglib动态代理,为什么a()调用当前类的b(),这个b()是父类的b(),而不是cglib生成的子类的b()呢?
@Component
public class MyTest {
public void a() {
System.out.println("it's a");
b();
}
public void b() {
System.out.println("it's b");
}
}
@Aspect
@Component
@Slf4j
@Getter
public class AspectLog {
@Pointcut("execution(public * com.vae1970.demo.aspect.MyTest.*(..))")
public void pointcut() {
}
@Before("pointcut()")
public void before(JoinPoint jp) {
Method method = (MethodSignature) jp.getSignature().getMethod();
System.out.println("log: function " + method.getName());
}
}
@RestController
public class TestController {
@Autowired
private MyTest myTest;
@GetMapping("/aspect")
public String aspect() {
myTest.a();
return "ok";
}
}
期望输出
log: function a
it's a
log: function b
it's b
实际输出
log: function a
it's a
it's b
我查看了cglib生成的MyTest类,a()和b()都做了代理,那为什么实际执行的时候,没有执行代理类的b()呢?
湖上湖
相关分类