当前位置:网站首页>Idea remote debugger
Idea remote debugger
2022-06-26 10:34:00 【My name is 985】
Preface
idea long-range debugger The project can find some that cannot be reproduced locally , But in jar Some problems in the package or on-site environment . The author takes a practical problem in work as an example , By the way, write down how to use idea long-range debugger
jar In bag File Troubleshooting and resolution of file missing exceptions
In one job , I will springboot The project into jar package , And then there was File Not Find It's abnormal . My code is as follows
public String getFileContent(Resource resource){
File file = resource.getFile();
try(FileInputStream fis = new FileInputStream(file)){
byte[] bytes = new bytes[fs.available()];
fs.read(bytes);
return new String(bytes);
} catch(Exception e){
...
}
return null;
}
- No problem in the local environment , But in jar The reasons for the problems in the package environment are as follows ( Refer to blog portal ):
- Because the local environment obtains the target file in the form of relative path , So there's no problem ;
- But it was a success jar After package , because jar A package is a separate file, not a folder , Therefore, it is not possible to obtain by relative path or absolute path jar Files inside the package .
// resolvent : Read in stream mode
public String getFileContent(Resource resource){
StringBuilder sb = new StringBuilder();
try(InputStreamReader isr = new InputStreamReader(resource.getInputStream(), StandardCharset.UTF-8)){
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine) != null){
sb.append(line);
}
return sb.toString();
} catch(Exception e){
...
}
return null;
}
Remote debugging and troubleshooting
In the local development environment , I have never been able to repeat this problem . But it doesn't work jar Package to start , It will be reported that the file cannot be found . At this time, I want to debug remotely jar To troubleshoot problems
First step : To configure idea Remote debugging

The second step
Make sure idea Your network can ping Pass target debugger Of jar Packet networkThe third step
start-up jar package
java -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8999 -jar ./xxx.jar
then jar Package printing is shown in the following figure , It means that the monitoring is successful 8999 port , Ready to be debugged remotely 
Step four
Select the just configured remote To start the
Then the console prints out this sentence , And it has been running . It means that remote debugging has been successfully started .
It should be noted that , long-range debugger Of jar Bag classes Follow the local code classes Agreement , Otherwise, you may not be able to debug due to inconsistent code .
边栏推荐
- What is in the method area - class file, class file constant pool, runtime constant pool
- Threading model in webrtc native
- MySQL 8th job
- Some problems to be considered when designing technical implementation scheme
- 方法区里面有什么——class文件、class文件常量池、运行时常量池
- 創建對象的時候堆內存的分配
- Little red book - Notes inspiration - project summary
- Detailed explanation of winsorflow quantum installation process
- What are the symbolic and direct references of the JVM
- Problems encountered in the application and development of Hongmeng and some roast
猜你喜欢

Small example of SSM project, detailed tutorial of SSM integration

36 qtextedit control input multiline text

What should the preview do?

Express (I) - easy to get started

哪些PHP开源作品值得关注

Appium自动化测试基础 — 移动端测试环境搭建(二)

Constraintlayout control uses full Raiders

exec系列函数(execl、execlp、execle、execv、execvp)使用

【LeetCode】59. 螺旋矩阵 II

基础-MySQL
随机推荐
What is a botnet
Pytest configuration file
开发者,微服务架构到底是什么?
US President signs community safety act to deal with gun issue
[depth first search] 312 Poke balloon
MySQL第四章总结
MySQL 12th job - Application of stored procedure
CentOS安装Redis多主多从集群
What are the symbolic and direct references of the JVM
The IE mode tab of Microsoft edge browser is stuck, which has been fixed by rolling back the update
JVM的符号引用和直接引用是什么
MySQL第十二次作业-存储过程的应用
What is LSP
看我在Map<String, String>集合中,存入Integer类型数据
904. 水果成篮
MySQL第十一作业-视图的应用
[sans titre]
Procedure Call Standard
Today's headline adaptation scheme code
The sixth MySQL job - query data - multiple conditions