这个问题的出现可能是因为在创建AgentBuilder时忘记添加拦截方法。
以下是正确设置代理的示例代码:
new AgentBuilder.Default()
.type(ElementMatchers.any())
.transform((builder, typeDescription, classLoader, module) -> builder
.method(ElementMatchers.any())
.intercept(MethodDelegation.to(MyInterceptor.class)))
.installOn(instrumentation);
其中,MyInterceptor
是一个拦截器类,可以在其中定义具体的拦截方法。