springboot开启远程调试
The run goal forks a process for the boot application. It is possible to specify jvm arguments to that forked process. The following configuration suspend the process until a debugger has joined on port 5005
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.1.12.RELEASE</version>
<configuration>
<jvmArguments>
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
</jvmArguments>
</configuration>
...
</plugin>
...
</plugins>
...
</build>
...
</project>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
These arguments can be specified on the command line as well, make sure to wrap that properly, that is:
mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
- 1
jar 命令开启远程调试
在执行jar的时候,添加上参数。如下:
java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n -jar demo.jar
- 1
如果想深入了解Java调试,那么去看一下这个吧。深入Java调试体系
问题
如果出现Connection refused。
首先检查一下端口8000的使用情况:
use:~/tomcat/logs # netstat -an|grep 8000
cp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
- 1
- 2
可见当前16808端口服务被绑定了回环地址,外部无法访问。即本地调试。
办法:
修改catalina.sh中一个参数。
if [ -z "$JPDA_TRANSPORT" ]; then
JPDA_TRANSPORT="dt_socket"
fi
if [ -z "$JPDA_ADDRESS" ]; then
JPDA_ADDRESS="0.0.0.0:8000"
fi
if [ -z "$JPDA_SUSPEND" ]; then
JPDA_SUSPEND="n"
fi
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
对JPDA_ADDRESS="localhost:8000" 把默认值(localhost:8000)改成0.0.0.0:8000。默认是本地ip调试也就是无法远程调试,0.0.0.0表示所有ip地址都能调试。
远程连上后再看端口情况:
root@VM-198-217-ubuntu:/opt/apache-tomcat-8.5.16/bin# netstat -an | grep 8000
tcp 0 0 10.133.198.217:8000 60.177.99.27:49998 ESTABLISHED
- 1
- 2
断开后是这样的:
root@VM-198-217-ubuntu:/opt/apache-tomcat-8.5.16/bin# netstat -an | grep 8000
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN
tcp 0 0 10.133.198.217:8000 60.177.99.27:49998 TIME_WAIT
- 1
- 2
- 3
idea连接远程端口进行远程debug
我已经在服务器上开启了远程调试,idea连接的步骤,直接上图。
edit configurations
远程调试配置
参数配置
将红框内的地址和端口号改成自己的。
启动远程调试
成功界面
请求一下试试
转自:https://blog.csdn.net/wsyw126/article/details/74853680
springboot开启远程调试的更多相关文章
- Java项目开启远程调试(tomcat、springboot)
当我们运行一个项目的时候,一般都是在本地进行debug.但是如果是一个分布式的微服务,这时候我们选择远程debug是我们开发的利器. 环境apache-tomcat-8.5.16 Linux 如何启用 ...
- springboot项目使用idea开启远程调试
远程调试是调试服务器的有效手段,远程服务器运行的应用可以在本地代码中打断点调试,能让开发人员准确定位服务器上的问题. 一.开启远程调试前提:本地代码与服务器代码一致, 二.开启远程调试步骤 1.开发工 ...
- tomcat如何正确的开启远程调试功能
在日常开发中,有时需要对远程服务器上的应用进行远程调试,对于tomcat,要进行远程调试其实很简单,只需要在启动tomcat时开启jpda服务即可. 什么是JPDA呢? JPDA(JavaPlatfo ...
- tomcat开启远程调试
tomcat开启远程调试模式: 需要在启动脚本中的 JAVA_OPTS='-server -Xms1024m -Xmx1024m -Xmn384m -Xss256k -XX:PermSize=128m ...
- tomcat如何正确的开启远程调试功能(转)
转自:http://blog.csdn.net/mhmyqn/article/details/49209541 版权声明:本文为博主原创文章,未经博主允许不得转载. 在日常开发中,有时需要对远程服务器 ...
- 【IDEA】【SpringBoot】基于idea对springboot程序远程调试
一.开启远程调试前提:本地代码与服务器代码一致(实测:不关键的代码稍微有点不一样好像也不会有多大问题). 二.开启远程调试步骤 1.开发工具配置 idea端打开Edit configurations, ...
- 惊呆了!Spring Boot 还能开启远程调试?
持续原创输出,点击上方蓝字关注我 目录 前言 什么是远程调试? 为什么要远程调试? 什么是JPDA? 如何开启调试? transport server suspend address onthrow ...
- eclipse 在weblogic部署的工程项目开启远程调试remote config eclipse远程调试配置
确认你的工程在weblogic中跑的起来,然后再结合eclipse debug配置+java debug运行模式搞个调试. 工程能跑起来没问题后,先在eclipse中,点击debug图标 然后点击De ...
- Intellij IDEA基于Springboot的远程调试
简介 本篇博客介绍一下在Intellij IDEA下对Springboot类型的项目的远程调试功能.所谓的远程调试就是服务端程序运行在一台远程服务器上,我们可以在本地服务端的代码(前提是本地的代码必须 ...
随机推荐
- webstorm中使用java的块凝视
webstorm中使用java的块凝视 有图有真相 使用java中非常方便得/**+enter就能高速创建类凝视.可是webstrom中没有现成的,所以我们得自己去创建一个,详细方法例如以下: 博主w ...
- Git经常使用命令
git --version 版本号号git help 帮助gitk 是个图形化的查看工具.gitk --all 所有分支历史-----------------------git pull 先拉git ...
- 关于 AlphaGo 论文的阅读笔记
这是Deepmind 公司在2016年1月28日Nature 杂志发表论文 <Mastering the game of Go with deep neural networks and tre ...
- ZipOutputStream 用法 小计
ZipOutputStream s = new ZipOutputStream(File.Create(ZipedFile)); 构造函数之后 文件就已经创建出来了 只是 0kb s.Write(bu ...
- shell-判断循环
shell条件测试 test 每个完整的合理的编程语言都具有条件判断的功能. bash可以使用test命令,[]和()操作,还有if/then结构 字符串判断 -n string 判断字符串长度非零 ...
- Mac OS command line TestNG - “Cannot find class in classpath” error
直接eclipse执行.xml文件可以正确执行 在mac下执行却总报错: [TestNG] [Error] Cannot find class in classpath 最后解决办法,classpat ...
- 计算IMEI号的校验位
计算IMEI号的校验位 移动设备国际识别码(IMEI:International Mobile Equipment Identification Number)是差别移动设备的标志,具有唯一性,贴在手 ...
- # Playables API(翻译)
The Playables API provides a way to create tools, effects or other gameplay mechanisms by organi ...
- Red Black Tree 红黑树 AVL trees 2-3 trees 2-3-4 trees B-trees Red-black trees Balanced search tree 平衡搜索树
小结: 1.红黑树:典型的用途是实现关联数组 2.旋转 当我们在对红黑树进行插入和删除等操作时,对树做了修改,那么可能会违背红黑树的性质.为了保持红黑树的性质,我们可以通过对树进行旋转,即修改树中某些 ...
- DuiLib笔记之CDuiString的bug
在C/C++中,当使用==比较两个对象时,推荐的风格是将常量置前 例如 if (0 == variable) { ... } 但在DuiLib中,CDuiString存在一个bug:在用==进行比较时 ...