idea 远程调用生产springboot的服务

 

1. 选择启动项,选择 Edit Confugurations  ...

2.  点击 + ,选择Remote 

idea 远程调用生产springboot的服务_第1张图片

3. 填写相关信息

Host: 目标服务器地址,所要监听的端口,(注意 不是服务的端口)

在目标服务器上 执行   sudo iptables -I INPUT -ptcp --dport 50001 -j ACCEPT ,以开启对应的监听的端口

复制 参数 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=50001 , 到本地分支启动的JVM参数中

idea 远程调用生产springboot的服务_第2张图片

4. 在参数启动项中, 配置  

idea 远程调用生产springboot的服务_第3张图片

idea 远程调用生产springboot的服务_第4张图片

 

5. 启动目标服务器, 带上一下标红的参数

java  -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=50001 -Xms256m -Xmx512m -XX:PermSize=64m -XX:MaxPermSize=128m -Xloggc:../logs/crm_web/gc.log -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -XX:InitiatingHeapOccupancyPercent=70 -XX:NewRatio=1 -XX:SurvivorRatio=6 -XX:G1ReservePercent=10 -XX:G1HeapRegionSize=32m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=../logs/crm_web/ -DLOG_DIR=../logs/crm_web -Dapollo.meta=http://apollo.xxx.sit -Dapollo.cluster=test -Dapp.id=crm_web -jar crm-web.jar --spring.profiles.active=test

通过log ,查看已经监听 50001 端口

5. debug 启动本地项目 , 等项目启动完毕后,然后debug 启动

控制台输出一下信息说明,已听远程接口成功 

Connected to the target VM, address: 'xxx:50001', transport: 'socket'

idea 远程调用生产springboot的服务_第5张图片

 

常见错误: 

查看是否开启多个调用; 是否目标服务器宕机了


Error running 'crm_prod': Unable to open debugger port (xxx:50001): java.net.ConnectException "Connection refused: connect

 可能是目标服务器 启动时,没有添加 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=50001 


Error running 'crm_prod': Unable to open debugger port (XXX:50001): java.net.ConnectException "Connection timed out: connect"

 

Disconnected from the target VM, address: 'XXX:50001', transport: 'socket'

你可能感兴趣的:(idea)