0


arthas查看spring bean及调用其方法

第一步:寻找类加载器

sc -d org.springframework.context.ApplicationContext

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

class-info        org.springframework.web.context.WebApplicationContext
 code-source       /home/admin/appname/target/appname.war/WEB-INF/lib/spring-web-3.2.16.RELEASE.jar
 name              org.springframework.web.context.WebApplicationContext
 isInterface       true
 isAnnotation      false
 isEnum            false
 isAnonymousClass  false
 isArray           false
 isLocalClass      false
 isMemberClass     false
 isPrimitive       false
 isSynthetic       false
 simple-name       WebApplicationContext
 modifier          abstract,interface,public
 annotation
 interfaces        org.springframework.context.ApplicationContext
 super-class
 class-loader      +-org.apache.catalina.loader.WebappClassLoader
                     +-java.net.URLClassLoader@5542c4ed
                       +-sun.misc.Launcher$AppClassLoader@18b4aac2
                         +-sun.misc.Launcher$ExtClassLoader@1cd072a9
 classLoaderHash   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]
标签: spring java

本文转载自: https://blog.csdn.net/chyang1999/article/details/134253075
版权归原作者 chyang1999 所有, 如有侵权,请联系我们删除。

“arthas查看spring bean及调用其方法”的评论:

还没有评论