cglib动态代理,为什么a()调用当前类的b(),这个b()是父类的b(),而不是cglib生成的子类的b()呢?@ComponentpublicclassMyTest{publicvoida(){System.out.println("it'sa");b();}publicvoidb(){System.out.println("it'sb");}}@Aspect@Component@Slf4j@GetterpublicclassAspectLog{@Pointcut("execution(public*com.vae1970.demo.aspect.MyTest.*(..))")publicvoidpointcut(){}@Before("pointcut()")publicvoidbefore(JoinPointjp){Methodmethod=(MethodSignature)jp.getSignature().getMethod();System.out.println("log:function"+method.getName());}}@RestControllerpublicclassTestController{@AutowiredprivateMyTestmyTest;@GetMapping("/aspect")publicStringaspect(){myTest.a();return"ok";}}期望输出log:functionait'salog:functionbit'sb实际输出log:functionait'sait'sb我查看了cglib生成的MyTest类,a()和b()都做了代理,那为什么实际执行的时候,没有执行代理类的b()呢?
梵蒂冈之花
相关分类