Arthas访问bean对象

发布时间 2023-07-24 17:52:27作者: JaxYoun

在使用Arthas中ognl命令时需要指定加载目标类的ClassLoader,所以需要先得到classLoader的hashCode

sc -d cn.seenew.habe.business.payorder.utils.UniPayParamFromDB  # 1.通过目标类名获取classLoader的hashCode【31cefde0】,利用这个hashCode访问bean

vmtool -x 3 --action getInstances --className cn.seenew.habe.business.payorder.utils.UniPayParamFromDB --express 'instances[0].uniPayPropVO.getWeChatMsgSrcId()' -c 31cefde0  # 调用静态成员变量的方法

vmtool -x 3 --action getInstances --className cn.seenew.habe.business.payorder.utils.UniPayParamFromDB --express 'instances[0].getMerchantIdByOrgCode('11')' -c 31cefde0  # 访问成员方法

vmtool -x 3 --action getInstances --className cn.seenew.habe.business.payorder.utils.UniPayParamFromDB --express 'instances[0].uniPayHosConfigVOList' -c 31cefde0  # 访问静态字段

vmtool -x 3 --action getInstances --className cn.seenew.habe.business.payorder.utils.UniPayParamFromDB --express 'instances[0].payChannelEntityMapper' -c 31cefde0  # 访问注入的bean

vmtool -x 3 --action getInstances --className cn.seenew.habe.business.payorder.utils.UniPayParamFromDB --express 'instances[0].uniPayHosConfigVOList.get(1)' -c 31cefde0  # 访问静态集合中的元素