一、Springboot 方式
1.服务启动端口是10000,远程监听端口是10001(这个端口是让IDEA debug监控的),这两个端口要在阿里云安全全组配置打开外网可访问(不用阿里云就无所谓了)
linux 启动环境:
项目名:access-10000.jar
address=10001 这是监听端口
java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10001 access-10000.jar
2.配置远程调试
3.添加ip地址Host=xx.yy.zz.nn ,和监控端口10001
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10001
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10001
-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10001
启动Springboot:显示监听10001
#java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10001 access-10000.jar
2018-09-01 15:01:56.782 INFO 10773 --- [ Thread-3] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@75f32542: startup date [Sat Sep 01 14:51:40 CST 2018]; root of context hierarchy
2018-09-01 15:01:56.784 INFO 10773 --- [ Thread-3] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
[root@izwz9i6slp0lyfpq28b2xoz kexin]# java -jar -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=10001 access-10000.jar
Listening for transport dt_socket at address: 10001
启动本地监听服务,启动成功
二、Tomcat方式
网上很多写的都是shit ,不能用,我这绝对可以用
1. IDEA 添加一个remote :
复制这个命令行: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10001
2.linux 服务器端:10001 端口表示 提供给你本地的服务的监听端口
# vim catalina.sh
JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=10001"
3.服务器 的tomcat端口是10000(可以随便指定)
4.启动测试
启动本地IDEA:提示连接到远程服务器
启动服务器tomcat:提示10001 监听端口启动