Aries' Blog

Freestyle technical blog

Debug spring-boot app with IntelliJ IDEA community

In intelliJ IDEA, if you debug a spring boot app by right-clicking the “main” class (e.g. Application.java) and select “Debug”, ClassNotFoundException may happen. As suggested on stackoverflow, we should use maven goal spring-boot:run to debug spring boot app. Also we should disable maven “forkmode”, otherwise breakpoint won’t work (I think we could use remote debugging with forkmode but haven’t tried).

Setup maven debug with “spring-boot:run” goal

  1. In IntelliJ menu, select Run -> Edit Configurations
  2. Click the “+” sign to Add New Configuration, select Maven in the dropdown
  3. Use spring-boot:run -Dfork=false as the Command line
  4. Click OK to save the configuration and debug as usual

Option 2 – Disable forkmode in pom.xml

  1. In pom.xml, add property spring-boot.run.fork and set it to false
  2. Sample pom.xml snippet
    <properties>
        <!-- For using breakpoint in Debug mode -->
        <spring-boot.run.fork>false</spring-boot.run.fork>
        <!-- Other Properties -->
    </properties>