arthas查看spring bean及调用其方法

编程入门 行业动态 更新时间:2024-10-11 19:25:42

arthas查看spring bean及调用其<a href=https://www.elefans.com/category/jswz/34/1771314.html style=方法"/>

arthas查看spring bean及调用其方法

第一步:寻找类加载器

sc -d org.springframework.context.ApplicationContext

因为可能存在很多个类加载器,每个classloader都有可能加载spring的ApplicationContext类,所以需要确定具体是哪个类加载器,找到其hashcode。

class-info        org.springframework.web.context.WebApplicationContextcode-source       /home/admin/appname/target/appname.war/WEB-INF/lib/spring-web-3.2.16.RELEASE.jarname              org.springframework.web.context.WebApplicationContextisInterface       trueisAnnotation      falseisEnum            falseisAnonymousClass  falseisArray           falseisLocalClass      falseisMemberClass     falseisPrimitive       falseisSynthetic       falsesimple-name       WebApplicationContextmodifier          abstract,interface,publicannotationinterfaces        org.springframework.context.ApplicationContextsuper-classclass-loader      +-org.apache.catalina.loader.WebappClassLoader+-java.URLClassLoader@5542c4ed+-sun.misc.Launcher$AppClassLoader@18b4aac2+-sun.misc.Launcher$ExtClassLoader@1cd072a9classLoaderHash   12dde243

第二步:查看bean

vmtool --action getInstances -c 12dde243 --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("ipNotifySwitch2ReservePriceSyncItemConfig")' -x 3
@IpNotifySwitch2ReservePriceSyncItemConfig[LOG=@Log4jLoggerAdapter[serialVersionUID=@Long[6182834493563598289],logger=@Logger[FQCN=@String[org.apache.log4j.Logger],class$org$apache$log4j$Logger=@Class[class org.apache.log4j.Logger],name=@String[com.example.demo.manager.base.config.IpNotifySwitch2ReservePriceSyncItemConfig],level=null,parent=@Logger[org.apache.log4j.Logger@3241a0a9],FQCN=@String[org.apache.log4j.Category],resourceBundle=null,repository=@Hierarchy[org.apache.log4j.Hierarchy@31bbea67],aai=null,additive=@Boolean[true],class$org$apache$log4j$Category=@Class[class org.apache.log4j.Category],],FQCN=@String[org.slf4j.impl.Log4jLoggerAdapter],traceCapable=@Boolean[true],serialVersionUID=@Long[9044267456635152283],serialVersionUID=@Long[7535258609338176893],name=@String[com.example.demo.manager.base.config.IpNotifySwitch2ReservePriceSyncItemConfig],],DIAMOND_GROUP=@String[demo],DIAMOND_DATAID=@String[com.example.demo.reservepricesync.itemids],itemIdSet=@HashSet[@Long[1111111],],
]

第三步:调用bean的方法

vmtool --action getInstances -c 12dde243 --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("ipNotifySwitch2ReservePriceSyncItemConfig").contains(11111L)' -x 3
@Boolean[false]

更多推荐

arthas查看spring bean及调用其方法

本文发布于:2023-11-16 07:47:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1614319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   arthas   spring   bean

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!