• arthas查看spring bean及调用其方法


    第一步:寻找类加载器

    sc -d org.springframework.context.ApplicationContext

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

    1. class-info org.springframework.web.context.WebApplicationContext
    2. code-source /home/admin/appname/target/appname.war/WEB-INF/lib/spring-web-3.2.16.RELEASE.jar
    3. name org.springframework.web.context.WebApplicationContext
    4. isInterface true
    5. isAnnotation false
    6. isEnum false
    7. isAnonymousClass false
    8. isArray false
    9. isLocalClass false
    10. isMemberClass false
    11. isPrimitive false
    12. isSynthetic false
    13. simple-name WebApplicationContext
    14. modifier abstract,interface,public
    15. annotation
    16. interfaces org.springframework.context.ApplicationContext
    17. super-class
    18. class-loader +-org.apache.catalina.loader.WebappClassLoader
    19. +-java.net.URLClassLoader@5542c4ed
    20. +-sun.misc.Launcher$AppClassLoader@18b4aac2
    21. +-sun.misc.Launcher$ExtClassLoader@1cd072a9
    22. classLoaderHash 12dde243

    第二步:查看bean

    vmtool --action getInstances -c 12dde243 --className org.springframework.context.ApplicationContext --express 'instances[0].getBean("ipNotifySwitch2ReservePriceSyncItemConfig")' -x 3
    1. @IpNotifySwitch2ReservePriceSyncItemConfig[
    2. LOG=@Log4jLoggerAdapter[
    3. serialVersionUID=@Long[6182834493563598289],
    4. logger=@Logger[
    5. FQCN=@String[org.apache.log4j.Logger],
    6. class$org$apache$log4j$Logger=@Class[class org.apache.log4j.Logger],
    7. name=@String[com.example.demo.manager.base.config.IpNotifySwitch2ReservePriceSyncItemConfig],
    8. level=null,
    9. parent=@Logger[org.apache.log4j.Logger@3241a0a9],
    10. FQCN=@String[org.apache.log4j.Category],
    11. resourceBundle=null,
    12. repository=@Hierarchy[org.apache.log4j.Hierarchy@31bbea67],
    13. aai=null,
    14. additive=@Boolean[true],
    15. class$org$apache$log4j$Category=@Class[class org.apache.log4j.Category],
    16. ],
    17. FQCN=@String[org.slf4j.impl.Log4jLoggerAdapter],
    18. traceCapable=@Boolean[true],
    19. serialVersionUID=@Long[9044267456635152283],
    20. serialVersionUID=@Long[7535258609338176893],
    21. name=@String[com.example.demo.manager.base.config.IpNotifySwitch2ReservePriceSyncItemConfig],
    22. ],
    23. DIAMOND_GROUP=@String[demo],
    24. DIAMOND_DATAID=@String[com.example.demo.reservepricesync.itemids],
    25. itemIdSet=@HashSet[
    26. @Long[1111111],
    27. ],
    28. ]

    第三步:调用bean的方法

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

  • 相关阅读:
    Jaeger
    SQL教学:掌握MySQL数据操作核心技能--DML语句基本操作之“增删改查“
    树和图的基础知识(洛谷)
    SparkSQL的Join的实现方式
    计算组内最大值对应记录
    基于低代码平台实现的知识文档管理系统
    性能测试高阶内容:了解TPS和RT之间关系
    实战 - 在Linux上部署各类软件
    PCIe寄存器之二
    JS--拷贝数组的方法(浅拷贝)
  • 原文地址:https://blog.csdn.net/chyang1999/article/details/134253075