Remote debug or local debug with tomcat embedded in Spring boot
When running application using mvn spring-boot:run
you can attach debugger like this:
mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:8000"
By providing spring-boot.run.jvmArguments
system property.
Alternatively, you can build application first and then run it using the following command:
java -jar app.jar -Dagentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000
When you provide debugger configuration using MAVEN_OPTS
, the debugger is attached to the Maven process, however, the application is running in a separate Java process without a debugger attached.
The easiest way to debug a Spring Boot application from an IDE is to not use Maven at all but instead directly launch the main
method from the @SpringBootApplication
class.