arthas反编译线上服务器应用包

相信大家在工作中可能会遇到这样的问题:有个bug你修复了,在测试环境测试通过,但是部署到生产环境,bug还是原来的bug,然后你就开始怀疑人生了。怀疑自己的代码还有bug、怀疑线上的数据问题、怀疑。。。。。。
其实如果大家对自己的代码质量有信心,你就可以直接找下运维,是不是部署的问题(部署包拿错了、压根没替换部署包、替换了没重启等)。这时候想要验证自己的猜想,直接使用arthas反编译看下相关代码是不是最新的就可以了。

下面划重点,如何在线上反编译看代码呢?


# 下载arthas
curl -O https://arthas.aliyun.com/arthas-boot.jar
# 运行arthas
java -jar arthas-boot.jar

[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 25892 /home/netcafe/netcafe-cloud/netcafe-pubwin.jar
  [2]: 26950 /home/netcafe/netcafe-cloud/netcafe-payment.jar
  [3]: 24088 /home/netcafe/netcafe-cloud/netcafe-auth.jar
  [4]: 25485 /home/netcafe/netcafe-cloud/netcafe-member.jar
  [5]: 16509 /home/netcafe/netcafe-cloud/netcafe-admin.jar
  [6]: 24575 /home/netcafe/netcafe-cloud/netcafe-gateway.jar

# 输入应用序号,比如我要反编译netcafe-pubwin里面的class,输入1即可
1 
# 输入反编译类的全路径
jad com.yn.netcafe.admin.config.WebConfiguration
 
#效果如下
ClassLoader:                                                                                                                                                                              
+-org.springframework.boot.loader.LaunchedURLClassLoader@2e0fa5d3                                                                                                                         
  +-sun.misc.Launcher$AppClassLoader@1b6d3586                                                                                                                                             
    +-sun.misc.Launcher$ExtClassLoader@34a0ef00                                                                                                                                           

Location:                                                                                                                                                                                 
file:/home/netcafe/netcafe-cloud/netcafe-admin.jar!/BOOT-INF/classes!/                                                                                                                    

        /*
         * Decompiled with CFR.
         * 
         * Could not load the following classes:
         *  com.yn.netcafe.auth.client.interceptor.ClientAuthRestInterceptor
         *  com.yn.netcafe.auth.client.interceptor.UserAuthRestInterceptor
         *  com.yn.netcafe.common.handler.GlobalExceptionHandler
         *  org.slf4j.Logger
         *  org.slf4j.LoggerFactory
         *  org.springframework.beans.factory.annotation.Autowired
         *  org.springframework.context.annotation.Bean
         *  org.springframework.context.annotation.Configuration
         *  org.springframework.context.annotation.Primary
         *  org.springframework.core.convert.converter.Converter
         *  org.springframework.data.redis.connection.RedisConnectionFactory
         *  org.springframework.data.redis.core.RedisTemplate
         *  org.springframework.data.redis.listener.RedisMessageListenerContainer
         *  org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer
         *  org.springframework.data.redis.serializer.RedisSerializer
         *  org.springframework.data.redis.serializer.StringRedisSerializer
         *  org.springframework.web.servlet.HandlerInterceptor
         *  org.springframework.web.servlet.config.annotation.InterceptorRegistry
         *  org.springframework.web.servlet.config.annotation.WebMvcConfigurer
         */
        package com.yn.netcafe.admin.config;
        
        import com.yn.netcafe.auth.client.interceptor.ClientAuthRestInterceptor;
        import com.yn.netcafe.auth.client.interceptor.UserAuthRestInterceptor;
        import com.yn.netcafe.common.handler.GlobalExceptionHandler;
        import java.sql.Timestamp;
        import java.text.SimpleDateFormat;
        import java.util.ArrayList;
        import java.util.Collections;
        import java.util.Date;
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.Configuration;
        import org.springframework.context.annotation.Primary;
        import org.springframework.core.convert.converter.Converter;
        import org.springframework.data.redis.connection.RedisConnectionFactory;
        import org.springframework.data.redis.core.RedisTemplate;
        import org.springframework.data.redis.listener.RedisMessageListenerContainer;
        import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
        import org.springframework.data.redis.serializer.RedisSerializer;
        import org.springframework.data.redis.serializer.StringRedisSerializer;
        import org.springframework.web.servlet.HandlerInterceptor;
        import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
        import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
        
        @Configuration(value="admimWebConfig")
        @Primary
        public class WebConfiguration
        implements WebMvcConfigurer {
            private static Logger logger = LoggerFactory.getLogger(WebConfiguration.class);
            @Autowired
            private RedisTemplate redisTemplate;
......

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值