Arthas简单使用备忘录
type
status
date
slug
summary
tags
category
icon
password
契机
Arthas在排查Java应用线上问题的时候有大用处,并且可以是热部署工具,这里我推荐几个我常用的方法
基本配置
- 下载arthas-boot.jar:https://github.com/alibaba/arthas/releases
- 直接java -jar arthas-boot.jar即可开始使用
- idea中安装两个插件:arthas idea & ArthasHotSwap
热部署
限制:无法修改类名、方法名,无法修改类属性名称,无法新增类属性,无法新增非静态方法
我们修改以下代码

然后comile一下

如果你远程服务器不止一个应用还需要指定一下jar包,这里java path也要是远程机器的真实地址
他的原理是把你的class文件上传到oss,然后在服务器下载。如果怕代码泄漏,需要自己去oss买个bucket配置上传到自己的oss,这里不做详细说明

然后在指定class右键执行工具

去宿主机部署代码,当看到succss就是成功了

常用命令

watch
trace
jad

thread
profiler

总结
- arthas热部署很好用,注意限制
- 介绍了常见的几个cmd
写到最后
Last update: 2024-03-20