9

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

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
  • How are you running the code? What does the build configuration look like? – meyer9 Mar 20 '17 at 04:45
  • @meyer9 Do you mean the “Run/Debug Configurations” panel, that pops up when choosing `Edit Configurations` on the popup-menu next to the green-triangle (Run) and green-bug (Debug) buttons? I added a screen-shot. – Basil Bourque Mar 20 '17 at 04:52
  • Yeah. See the warning at the bottom? That means your run configuration is messed up in some way. You possibly didn't add it to the right project, or didn't include the correct libraries. Even if it works in some convoluted way, I doubt the debugger will be able to find the lines you specified. – meyer9 Mar 20 '17 at 04:54
  • @meyer9 And yet my code is contained in physical folders following that exact package name, as created by the Maven archetype. I added screenshot showing that physical folder path. Do I need to further inform IntelliJ about the structure of the Maven project it imported? – Basil Bourque Mar 20 '17 at 05:24
  • Source roots are not configured correctly, check if [this answer](http://stackoverflow.com/a/42869905/104891) helps. If it doesn't check [another answer](http://stackoverflow.com/a/42427510/104891) for further diagnostics. – CrazyCoder Mar 20 '17 at 05:27

1 Answers1

6

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>
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154