Basil Bourque
Basil Bourque

Reputation: 338614

Debugger does not stop on breakpoints in simple Maven project in IntelliJ 2017.1

Into IntelliJ 2017.1 RC, I imported a simple Maven project created with the Quickstart Archetype.

When clicking the green-bug-icon to run in debug mode, the debugger panel does appear. Clicking the View Breakpoints icon shows that I do indeed have multiple breakpoints in place, created by clicking in the gutter of the code editor. Yet all those breakpoints are bypassed, and the code execution completes.

Is there some trick to making the IntelliJ debugger, well, debug?

I am new to IntelliJ, more familiar with NetBeans.

screenshot of Run/Debug Configurations panel

screenshot of breakpoints appearing in code-editor and in Breakpoints panel

screenshot of folder path to .java code file

Upvotes: 10

Views: 10387

Answers (1)

Basil Bourque
Basil Bourque

Reputation: 338614

Failed import of Maven project into IntelliJ

Something went wrong with the import of the Maven project into IntelliJ.

Try again.

  1. Delete .idea and myapp.iml items from project folder.
  2. Re-import Maven project into IntelliJ.
  3. Build project.
    Perhaps context-click in the code editor and choose Recompile MyApp.java
  4. Debug.
    Click the green-bug to debug, or context-click to choose Debug 'MyApp.main()'

Then debugger works as expected, stopping on breakpoints.


Tip: Before importing a Maven project, edit the POM to specify a Java version as the compiler source & target. If omitted you get Maven's default of compiling as Java 5 (1.5) code. Per the Maven page, Setting the -source and -target of the Java Compiler inject these four lines into your POM file, a pair of tags inside a properties tag.

Here we specify Java 8 (1.8) be used by the compiler.

<project>
  [...]
  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
  [...]
</project>

Upvotes: 6

Related Questions