Your Site Title

Java JDB

jdb -attach <address> 关联一个VM -sourcepath 指定源码路径, 使用:分隔 -classpath 指定class路径, 使用:分隔

jdb -attach 1099 jdb -listen 8088 jdb –listenany jdb -tclient jdb -tserver

// 指定源码路径 javac -sourcepath src -d target src/mypackage/Main.java # if you have multiple files, you can always do find . -name “*.java” -exec javac -sourcepath src -d target {} \;

	jdb -sourcepath src -classpath target mypackage.Main

打开Debug模式

Spring Boot Maven:

	mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$PORT_NUMBER"

Maven Test:

	mvn -Dmaven.surefire.debug test
	mvn -Dmaven.surefire.debug="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent -Djava.compiler=NONE" test

Spring Boot Jar:

	java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$PORT_NUMBER -jar $UBERJAR_FILENAME

jdb command

threads – list threads classes – list currently known classes class

Reference

jdb - The Java Debugger
JDB - Quick Guide
Spring Boot Maven Plugin
Debugging Spring Applications
JDB | Using Java Command Line Debugging Tool
Dica-Developer/vim-jdb