当前位置:网站首页>Arthas 常用命令
Arthas 常用命令
2022-08-01 19:38:00 【猪悟道】
线上程序 在线调试工具:Arthas
Arthas 常用命令
1.查看源码:jad

2.清屏:cls

3.查看静态资源信息:getstatic
package com.demo.common;
import com.demo.entity.User;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/** * Description: 静态资源 * * @Author: * @Date: 2022-07-29 22:05 * @version: V1.0.0 */
@Component
public class DemoCommon {
private static Map<String, User> USER_MAP;
static {
USER_MAP = new HashMap<>();
USER_MAP.put("moon",new User("moon",18));
USER_MAP.put("starts",new User("starts",18));
USER_MAP.put("earth",new User("earth",18));
}
}

4.查看方法返回值:watch
## 1.发起请求
## http://127.0.0.1/test/query
## 2.如果只观察一次,则
watch com.demo.controller.Test query -n 1

5.查看方法耗时:trace
## 1.发起请求
## http://127.0.0.1/test/login
## 2.如果只观察一次,则
trace com.demo.service.impl.TestServiceImpl login
## 3.如果只观察异常耗时,则(毫秒),即耗时大于2500ms才打印
trace com.demo.service.impl.TestServiceImpl login '#cost > 2500'

线上调试(临时修改源码)
1.反编译为Java文件
## 1.命令
jad --source-only com.demo.controller.Test > C:\Users\Administrator\Desktop\source_code\Test.java

## 2.修改(Sublime)如果是在Linux系统,则可使用 VIM 命令

2.内存编译(在内存将源码编译为Class文件)
## 1.命令
mc C:\\Users\\Administrator\\Desktop\\source_code\\Test.java -d C:\\Users\\Administrator\\Desktop\\source_code\\

3.类增强
## 1.命令(修改方法返回值为 8 )
retransform C:\\Users\\Administrator\\Desktop\\source_code\\com\\demo\\controller\\Test.class
## 2.查看已增强的类(可重复执行1命令)
retransform -l
## 3.请求测试
## http://127.0.0.1/test/query
## 4.增强恢复,先清除增强类
retransform -d 1
retransform -d 2
## 5.重置
reset

测试结果
重置
重置后结果
reset 不生效,则在重置前执行一下其他命令,如:trace com.demo.controller.Test query
然后再执行reset即可

测试代码
用户
package com.demo.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
/** * Description: 用户 * * @Author: * @Date: 2022-07-29 21:17 * @version: V1.0.0 */
@Data
@AllArgsConstructor
public class User {
private String name;
private int age;
}
控制层
package com.demo.controller;
import com.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** * Description: 测试 * * @Author: * @Date: 2022-07-25 23:30 * @version: V1.0.0 */
@CrossOrigin
@RestController
@RequestMapping("/test")
public class Test {
private TestService testService;
@Autowired
public Test(TestService testService){
this.testService = testService;
}
/** * 登录 */
@GetMapping("/login")
public void login(){
testService.login();
}
/** * 查询 * @return */
@GetMapping("/query")
public int query(){
return 0;
}
}
测试接口
package com.demo.service;
import com.demo.entity.User;
/** * Description: 测试服务 * * @Author: * @Date: 2022-07-29 21:16 * @version: V1.0.0 */
public interface TestService {
/** * 登录 * @return */
User login();
}
测试实现
package com.demo.service.impl;
import com.demo.entity.User;
import com.demo.service.TestService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/** * Description: 测试服务 * * @Author: * @Date: 2022-07-29 21:19 * @version: V1.0.0 */
@Slf4j
@Service
public class TestServiceImpl implements TestService {
@Override
public User login() {
checkUserCurrentAddress();
checkVerificationCode();
checkDynamicPass();
return new User("moon",1);
}
/** * 校验 用户当前属地 */
private void checkUserCurrentAddress(){
try {
Thread.sleep(400);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
log.info("Check User Current Address ...");
}
/** * 校验 验证码 */
private void checkVerificationCode(){
try {
Thread.sleep(800);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
log.info("Check Verification Code ...");
}
/** * 校验 密码 */
private void checkDynamicPass(){
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
log.info("Check Dynamic Pass ...");
}
}
静态资源
package com.demo.common;
import com.demo.entity.User;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/** * Description: 静态资源 * * @Author: * @Date: 2022-07-29 22:05 * @version: V1.0.0 */
@Component
public class DemoCommon {
private static Map<String, User> USER_MAP;
static {
USER_MAP = new HashMap<>();
USER_MAP.put("moon",new User("moon",18));
USER_MAP.put("starts",new User("starts",18));
USER_MAP.put("earth",new User("earth",18));
}
}
边栏推荐
猜你喜欢

智能硬件开发怎么做?机智云全套自助式开发工具助力高效开发

【蓝桥杯选拔赛真题47】Scratch潜艇游戏 少儿编程scratch蓝桥杯选拔赛真题讲解

Combining two ordered arrays

Library website construction source code sharing

Website construction process

30天刷题计划(五)

网站建设流程

17. Load balancing

BN BatchNorm + BatchNorm的替代新方法KNConvNets

MLX90640 Infrared Thermal Imager Temperature Measurement Module Development Notes (Complete)
随机推荐
Heavy cover special | build the first line of defense, cloud firewall offensive and defensive drills best practices
57: Chapter 5: Develop admin management services: 10: Develop [get files from MongoDB's GridFS, interface]; (from GridFS, get the SOP of files) (Do not use MongoDB's service, you can exclude its autom
nacos安装与配置
GBase 8c中怎么查询数据库配置参数,例如datestyle。使用什么函数或者语法呢?
Creo5.0草绘如何绘制正六边形
Win11如何开启剪贴板自动复制?Win11开启剪贴板自动复制的方法
Gradle系列——Gradle文件操作,Gradle依赖(基于Gradle文档7.5)day3-1
即时通讯开发移动端弱网络优化方法总结
10 个 PHP 代码安全漏洞扫描程序
Source code analysis of GZIPOutputStream class
Combining two ordered arrays
18、分布式配置中心nacos
SaaS管理系统的应用优势在哪里?如何高效提升食品制造业数智化发展水平?
哈哈!一个 print 函数,还挺会玩啊!
1个小时!从零制作一个! AI图片识别WEB应用!
部署zabbix
Win10, the middle mouse button cannot zoom in and out in proe/creo
Oracle排序某个字段, 如果这个varchar2类型的字段有数字也有文字 , 怎么按照数字大小排序?
Choosing the right DevOps tool starts with understanding DevOps
XSS range intermediate bypass