Debugging with Maven

This short guide describes how to simplify debugging by using profiles.

First you need to add a new profile ‘debug’ to your ~/.m2/settings.xml.

      <!-- Allow configuration via system properties -->
      <!-- Configure exec plugin -->
      <exec.args>${debug.args} -classpath %classpath ${exec.mainClass}</exec.args>
      <!-- Configure Spring Boot plugin -->

Whenever you want to debug, just activate the debug profile.

mvn -Pdebug exec:exec -Dexec.mainClass="com.example.demo.Application"
mvn -Pdebug spring-boot:run

Use system properties to configure the debugging parameters.

mvn -Pdebug -Ddebug.suspend=y ...