arthas使用参考arthas文档
sc -d 类名 获取到类加载器哈希
sc -d com.test.service.TestServiceImpl
得到:
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxx
classLoaderHash 18b4aac2
根据类加载器调用bean方法
vmtool --action getInstances -c 18b4aac2 --className org.springframework.context.ApplicationContext --express '#data=new com.test.entity.TestEntity(),#data.setId("1220091926917696"),#data.setA("22s4003789049857"),instances[0].getBean("testServiceImpl").doSomeBis(#data)' -x 3
创建TestEntity对象作为参数调用testServiceImplbean的doSomeBis方法
监控方法入参与返回值
现有方法
package com.test.demo;
@Service
public class Test{
public String get(String req1, String req2){
return "test";
}
}
#获取test()方法的第一个参数的方法,监控三次
watch com.test.demo.Test get'{params[0].hashCode()}' -x 3
#获取test()方法的所有传参及返回值,监控三次
watch com.test.demo.Test get'{params,returnObj}' -x 3