凡事都在事上磨,这样才能精进,成长进步提高! ------ 博客园首页

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 兼容性更好。

 

posted @ 2026-07-19 13:35  追风fc  阅读(13)  评论(0)    收藏  举报