当前位置:网站首页>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 中的代码要保持一致
总结
欢迎指出我的错误!
边栏推荐
- Leetcode daily question (931. minimum falling path sum)
- 307. Range Sum Query - Mutable
- Intelligent home design and development
- Flink learning notes (VIII) multi stream conversion
- Idea uses the MVN command to package and report an error, which is not available
- Jestson nano downloads updated kernel and DTB from TFTP server
- Leetcode daily question (2232. minimize result by addressing parents to expression)
- Jetson nano custom boot icon kernel logo CBOOT logo
- Construction and test of TFTP server under unbuntu (Debian)
- Word segmentation in full-text indexing
猜你喜欢
![[CSDN] C1 training problem analysis_ Part III_ JS Foundation](/img/b2/68d53ad09688f7fc922ac65e104f15.png)
[CSDN] C1 training problem analysis_ Part III_ JS Foundation

一款开源的Markdown转富文本编辑器的实现原理剖析

Difference of EOF

Matlab reads hexadecimal numbers and converts them into signed short
![[CSDN]C1训练题解析_第三部分_JS基础](/img/b2/68d53ad09688f7fc922ac65e104f15.png)
[CSDN]C1训练题解析_第三部分_JS基础
![顺利毕业[2]-学生健康管理系统 功能开发中。。。](/img/91/72cdea3eb3f61315595330d2c9016d.png)
顺利毕业[2]-学生健康管理系统 功能开发中。。。

numpy. Reshape() and resize() functions

Win10 install elk

Trial of the combination of RDS and crawler

The cyclic shift of PUCCH in NR channel is generated by MATLAB
随机推荐
Solve the problem of disordered code in vscode development, output Chinese and open source code
Flink learning notes (VIII) multi stream conversion
Nr--- Pusch I: sorting out the agreement process
Spark 集群安装与部署
【顺利毕业】[1]-游览 [学生管理信息系统]
Logstash+jdbc data synchronization +head display problems
用Redis实现分布式锁
The rise and fall of mobile phones in my perspective these 10 years
Make the most basic root file system of Jetson nano and mount NFS file system on the server
PolyWorks script development learning notes (III) -treeview advanced operation
Leetcode daily question (2090. K radius subarray averages)
Jestson Nano自定义根文件系统创建(支持NVIDIA图形库的最小根文件系统)
LeetCode每日一题(516. Longest Palindromic Subsequence)
Common software open source protocols
顺利毕业[3]-博客系统 更新中。。。
LeetCode每日一题(2305. Fair Distribution of Cookies)
LeetCode每日一题(2232. Minimize Result by Adding Parentheses to Expression)
The cyclic shift of PUCCH in NR channel is generated by MATLAB
[combinatorics] Introduction to Combinatorics (combinatorial thought 2: mathematical induction | mathematical induction promotion | multiple induction thought)
1300. sum of varied array closed to target