通过arthas 打印spring项目的配置

spring程序运行起来后, 有时候想看看配置是否正确或者spring项目的一些默认配置项是什么.可以通过阿里云的arthas 将内存中的spring 配置类打印出来.

查找实例的类加载器

[arthas@439]$ sc -d org.springframework.boot.autoconfigure.web.ServerProperties
 class-info        org.springframework.boot.autoconfigure.web.ServerProperties
 code-source       /usr/share/octopus/lib/spring-boot-autoconfigure-3.2.1.jar
 name              org.springframework.boot.autoconfigure.web.ServerProperties
 isInterface       false
 isAnnotation      false
 isEnum            false
 isAnonymousClass  false
 isArray           false
 isLocalClass      false
 isMemberClass     false
 isPrimitive       false
 isSynthetic       false
 simple-name       ServerProperties
 modifier          public
 annotation        org.springframework.boot.context.properties.ConfigurationProperties
 interfaces
 super-class       +-java.lang.Object
 class-loader      +-jdk.internal.loader.ClassLoaders$AppClassLoader@5ffd2b27
                     +-jdk.internal.loader.ClassLoaders$PlatformClassLoader@34cd072c
 classLoaderHash   5ffd2b27

打印类情况

[arthas@439]$ vmtool -c  5ffd2b27 --action getInstances  --className org.springframework.boot.autoconfigure.web.ServerProperties  -x 2
@ServerProperties[][
    @ServerProperties[
        port=@Integer[19091],
        address=null,
        error=@ErrorProperties[org.springframework.boot.autoconfigure.web.ErrorProperties@2b101c68],
        forwardHeadersStrategy=null,
        serverHeader=null,
        maxHttpRequestHeaderSize=@DataSize[8192B],
        shutdown=@Shutdown[IMMEDIATE],
        ssl=@Ssl[org.springframework.boot.web.server.Ssl@4d349bbc],
        compression=@Compression[org.springframework.boot.web.server.Compression@195400d1],
        http2=@Http2[org.springframework.boot.web.server.Http2@1654070d],
        servlet=@Servlet[org.springframework.boot.autoconfigure.web.ServerProperties$Servlet@3d8cbaf3],
        reactive=@Reactive[org.springframework.boot.autoconfigure.web.ServerProperties$Reactive@548c3f85],
        tomcat=@Tomcat[org.springframework.boot.autoconfigure.web.ServerProperties$Tomcat@6d67ef4d],
        jetty=@Jetty[org.springframework.boot.autoconfigure.web.ServerProperties$Jetty@5b3df183],
        netty=@Netty[org.springframework.boot.autoconfigure.web.ServerProperties$Netty@3be9335],
        undertow=@Undertow[org.springframework.boot.autoconfigure.web.ServerProperties$Undertow@36fbf4d0],
    ],
]

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.