当前位置:网站首页>IDEA远程断点调试jar包项目
IDEA远程断点调试jar包项目
2022-07-03 09:04:00 【单手入天象】
前言
springboot 项目在开发完,打成一个 jar 包,放到服务器运行时,如果报错了,怎样排查比较方便?
要是开发环境,我们可以在 IDEA 打上断点,轻松调试,但是现在已经是一个 jar 包在服务器运行着了。
我们可以远程断点调试 jar 包项目吗?
可以。
一、准备工作
1. jar包应用
自己创建一个 springboot 项目,里面很简单,就写一个用来调试的接口:
@GetMapping("/test")
public String test(){
int i = 1 / 0;
System.out.println(i);
return "success";
}
打成 jar 包,上传到一台虚拟机节点,我这里上传到了 192.168.201.4
1. IDEA配置
点击 Edit Configurations
选择 Remote
填写信息
注意:我们只需要修改 Host 那一项就可以了,改成我们远程运行 jar 包的节点 ip
二、断点调试
1. 运行jar包
在上一步, IDEA 自动生成了一串东西,就是这个:
复制它 !
去到虚拟机节点下,运行命令启动项目:
java 复制的指令 -jar 包名
我实际的运行命令:
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 -jar demo.jar
控制台可以看到,它正在监听 5005 端口
2. 访问接口
http://192.168.201.4:8087/test
3. 进来断点

三、注意点
我这里故意让程序抛异常,并打印信息,可以看到,跟我们本地断点有点不一样,IDEA 的控制台是不会输出信息的,我们只能在虚拟机节点的控制台查看
IDEA 的控制台始终显示:

不过堆栈信息,运行中的对象属性等,还是可以在 IDEA 那里看到的
还有,运行的 jar 包的代码和 IDEA 中的代码要保持一致
总结
欢迎指出我的错误!
边栏推荐
- [combinatorics] Introduction to Combinatorics (context of combinatorics | skills of combinatorics | thought of combinatorics 1: one-to-one correspondence)
- PolyWorks script development learning notes (I) - script development environment
- Flink学习笔记(八)多流转换
- ERROR: certificate common name “*.” doesn’t match requested ho
- Leetcode daily question (516. long palindromic subsequence)
- Failed building wheel for argon2 cffi when installing Jupiter
- Flask+supervisor installation realizes background process resident
- 1300. sum of varied array closed to target
- Flink learning notes (XI) table API and SQL
- UCI and data multiplexing are transmitted on Pusch - placement of data and UCI positions (Part III)
猜你喜欢

PolyWorks script development learning notes (4) - data import and alignment using file import

The cyclic shift of PUCCH in NR channel is generated by MATLAB

MySQL data manipulation language DML common commands

PRACH --- originator

Leetcode daily question (2090. K radius subarray averages)

PolyWorks script development learning notes (II) -treeview basic operations

Common software open source protocols

Trial of the combination of RDS and crawler

小王叔叔的博客目录【持续更新中】

Flink-CDC实践(含实操步骤与截图)
随机推荐
Jestson Nano 从tftp服务器下载更新kernel和dtb
Flink learning notes (10) Flink fault tolerance mechanism
PowerDesigner does not display table fields, only displays table names and references, which can be modified synchronously
【22毕业季】我是毕业生yo~
UCI and data multiplexing are transmitted on Pusch - determine the bit number of harqack, csi1 and csi2 (Part II)
Difference of EOF
Directory and switching operation in file system
Nr--- Pusch I: sorting out the agreement process
1922. Count Good Numbers
About the configuration of vs2008+rade CATIA v5r22
Flink CDC practice (including practical steps and screenshots)
【男保姆式】教你打开第一个微信小程序
LeetCode每日一题(985. Sum of Even Numbers After Queries)
Integrated use of interlij idea and sonarqube
Database execution error: SQL_ mode only_ full_ group_ by:
LeetCode每日一题(2115. Find All Possible Recipes from Given Supplies)
Trial of the combination of RDS and crawler
Nodemcu-esp8266 development (vscode+platformio+arduino framework): Part 2 --blinker_ Hello_ WiFi (lighting technology - Mobile App control routine)
Solve editor MD uploads pictures and cannot get the picture address
ERROR: certificate common name “www.mysql.com” doesn’t match requested host name “137.254.60.11”.