jconsole 远程
你用 -agentlib:jdwp 配置了 JDWP 调试,但 jconsole 需要的是 JMX 参数,不是 JDWP 参数。
解决方案:在 IDE Run Configuration 的 VM arguments 中同时添加 JMX 相关参数:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.rmi.port=9999
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=jdk.management.agent/jdk.management.agent=ALL-UNNAMED
然后:
用 IDE Debug 按钮 连接 5005 端口进行调试
用 jconsole 连接 9999 端口 进行监控
或者直接用 IDEA 自带的 Profiler/Monitor 工具,它对 JDK 21 兼容性更好。
因为相信,所以看见.

浙公网安备 33010602011771号