当前位置:网站首页>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 中的代码要保持一致
总结
欢迎指出我的错误!
边栏推荐
- Modify idea code
- Leetcode daily question (1024. video sticking)
- Flink-CDC实践(含实操步骤与截图)
- 【顺利毕业】[1]-游览 [学生管理信息系统]
- LeetCode每日一题(1024. Video Stitching)
- 1922. Count Good Numbers
- LeetCode每日一题(745. Prefix and Suffix Search)
- LeetCode每日一题(2090. K Radius Subarray Averages)
- Development of fire power monitoring system
- Flink学习笔记(八)多流转换
猜你喜欢

Flask+supervisor installation realizes background process resident

Nodemcu-esp8266 development board to build Arduino ide development environment

Directory and switching operation in file system

Solve the problem of disordered code in vscode development, output Chinese and open source code

文件系统中的目录与切换操作

How MySQL modifies null to not null
![【顺利毕业】[1]-游览 [学生管理信息系统]](/img/91/72cdea3eb3f61315595330d2c9016d.png)
【顺利毕业】[1]-游览 [学生管理信息系统]

MySQL data manipulation language DML common commands

Flink学习笔记(十一)Table API 和 SQL

全球KYC服务商ADVANCE.AI 活体检测产品通过ISO国际安全认证 产品能力再上一新台阶
随机推荐
Jetson Nano 自定义启动图标kernel Logo cboot logo
PIP configuring domestic sources
[CSDN]C1训练题解析_第三部分_JS基础
UCI and data multiplexing are transmitted on Pusch - determine the bit number of harqack, csi1 and csi2 (Part II)
Leetcode daily question (745. prefix and suffix search)
Flink学习笔记(十)Flink容错机制
CATIA automation object architecture - detailed explanation of application objects (I) document/settingcontrollers
Development of fire evacuation system
LeetCode每日一题(931. Minimum Falling Path Sum)
LeetCode每日一题(745. Prefix and Suffix Search)
LeetCode每日一题(2090. K Radius Subarray Averages)
用Redis实现分布式锁
1300. sum of varied array closed to target
Jestson nano downloads updated kernel and DTB from TFTP server
顺利毕业[2]-学生健康管理系统 功能开发中。。。
Convert IP address to int
Desktop icon recognition based on OpenCV
Flink learning notes (VIII) multi stream conversion
【顺利毕业】[1]-游览 [学生管理信息系统]
How does the nr-prach receiver detect the relationship between prembleid and Ta