本地使用IDEA调试远程部署的程序代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

本地使⽤IDEA调试远程部署的程序代码
⽇常开发⼯作中经常会出现代码本地运⾏⽆问题,但部署到服务器中功能⽆法正常使⽤。

本篇博客介绍如何使⽤IDEA像调试本地代码⼀样,调试远端代码。

服务端⼝:远端部署的应⽤对外开放的访问端⼝。

调试端⼝:远端部署的应⽤额外开启的对外调试端⼝。

当远端服务被调⽤时,触发本地IDEA上的调试断点,⽤于调试远程服务器上部署的应⽤程序。

实现步骤
1. 创建springboot⼯程,并指定服务端⼝。

(当然也可以不指定,默认8080)
application.properties
server.port=18080
2. 配置本地IDEA远程连接。

Name:远程连接名称,任意写。

Host:远程主机。

(服务部署服务器)
Port:调试端⼝
Command line arguments for remote JVM:填写好主机、端⼝信息后,IDEA会⾃动⽣成命令⾏,⽤于远端服务启动参数。

3. 打包应⽤,并将Jar包上传⾄服务器。

4. 启动服务。

java -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8088 -jar remote-debug-demo-0.0.1-SNAPSHOT.jar
服务器启动⽇志:
[root@iZf8ozvj95ui19Z code]# java -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8088 -jar remote-debug-demo-0.0.1-SNAPSHOT.jar
Listening for transport dt_socket at address: 8088
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.1.RELEASE)
2020-06-23 20:14:16.975 INFO 3206 --- [ main] com.ari.RemoteDebugDemoApplication : Starting RemoteDebugDemoApplication v0.0.1-SNAPSHOT on iZf8ozvj95ui19Z with PID 3206 (/usr/code/remote-debug-demo-0.0.1 2020-06-23 20:14:16.980 INFO 3206 --- [ main] com.ari.RemoteDebugDemoApplication : No active profile set, falling back to default profiles: default
2020-06-23 20:14:20.567 INFO 3206 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 18080 (http)
2020-06-23 20:14:20.630 INFO 3206 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-06-23 20:14:20.631 INFO 3206 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-06-23 20:14:21.020 INFO 3206 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-06-23 20:14:21.020 INFO 3206 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3904 ms
2020-06-23 20:14:22.194 INFO 3206 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-23 20:14:23.003 INFO 3206 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 18080 (http) with context path ''
2020-06-23 20:14:23.041 INFO 3206 --- [ main] com.ari.RemoteDebugDemoApplication : Started RemoteDebugDemoApplication in 7.484 seconds (JVM running for 8.882)
2020-06-23 20:17:25.379 INFO 3206 --- [io-18080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-06-23 20:17:25.379 INFO 3206 --- [io-18080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2020-06-23 20:17:25.415 INFO 3206 --- [io-18080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 36 ms
Listening for transport dt_socket at address:8088 调试端⼝:8088
Tomcat started on port(s): 18080 (http) with context path '' 服务端⼝:18080
5. 启动本地远程连接,控制台提⽰”成功连接到远程调试端⼝“
Connected to the target VM, address: '118.190.209.24:8088', transport: 'socket'
6. 本地打断点并重新访问远端服务,本地成功进⼊DEBUG
原视频链接:。

相关文档
最新文档