• 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]

  • 相关阅读:
    c++替换字符的方法
    深入源码剖析ThreadPoolExecutor的工作原理
    类加载中的执行顺序
    Arduino UNO + DS1302简单获取时间并串口打印
    Fiddler之Replay功能详解
    人脸识别数据库,RGB和IR都有
    【Python从0到1】第四篇:使用库
    JAVA 面试大全系列-基础篇(持续跟新)
    Centos8系统配置Redis实现开机自启
    Java~常见的工具类 Collections、Arrays
  • 原文地址:https://blog.csdn.net/chyang1999/article/details/134253075