当前位置:网站首页>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 .
边栏推荐
- Some problems to be considered when designing technical implementation scheme
- Threading model in webrtc native
- 挖财商学院证券开户安全嘛?
- June training (the 26th day) - collective search
- Use of exec series functions (EXECL, execlp, execle, execv, execvp)
- Establishment of smart dialogue platform for wechat official account
- MySQL Chapter 6 Summary
- String constant pool, class constant pool, and runtime constant pool
- VS或Qt编译链接过程中出现“无法解析的外部符号”的原因:
- US President signs community safety act to deal with gun issue
猜你喜欢

Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc

MySQL第十一作業-視圖的應用

字符串常量池、class常量池和运行时常量池

Small example of SSM project, detailed tutorial of SSM integration

A list of common methods for customizing paint and canvas of view

Flutter与原生通信(上)

P1296 whispers of cows (quick row + binary search)

MySQL 13th job - transaction management

3行3列整形二维数组,求对角之和

創建對象的時候堆內存的分配
随机推荐
Blog article index summary -- Software Engineering
Appium自动化测试基础 — 移动端测试环境搭建(二)
Common interview questions of binary tree
JVM的符号引用和直接引用是什么
Global and Chinese market for change and configuration management software 2022-2028: Research Report on technology, participants, trends, market size and share
Procedure Call Standard
About multi table query of MySQL
JS reverse | four libraries and one platform response data encryption
How to change the QR code material color of wechat applet
Dynamic library connection - symbol conflict - global symbol intervention
Développeur, quelle est l'architecture des microservices?
Global and Chinese market of amateur football helmets 2022-2028: Research Report on technology, participants, trends, market size and share
首批12家企业入驻!广州首个集中展销老字号产品专柜开张
Call API interface to generate QR code of wechat applet with different colors
MySQL第十次作业-视图
MySQL project 8 summary
When will JVM garbage collection enter the older generation
【Leetcode】76. 最小覆盖子串
Global and Chinese market of aluminum sunshade systems 2022-2028: Research Report on technology, participants, trends, market size and share
The IE mode tab of Microsoft edge browser is stuck, which has been fixed by rolling back the update