Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 340
Basil Bourque Avatar asked Mar 20 '17 04:03

Basil Bourque


People also ask

How do I stop debugging in IntelliJ?

Terminate a debugger session Click the Stop button in the Debug tool window. Alternatively, press Ctrl+F2 and select the process to terminate (if there are two or more of them).

Why debug is not working in IntelliJ?

To solve this, simply remove the jar of the debugged module from all modules' dependencies in the Project Structure. If you do not know which modules have the debugged module jar as dependencies, you can use some tools (Eg. Sublime Text, bash, ...) to search for the module name which is stored in Intellij *.

How do you fix method breakpoints may dramatically slow down debugging?

Practical advice that I follow: 1. mute all the breakpoints while the app is coming up 2. enable breakpoints only while debugging that flow. Of course, it won't help if you are trying to debug something which happens during app startup.


1 Answers

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>
like image 61
Basil Bourque Avatar answered Oct 05 '22 15:10

Basil Bourque