0

I have a spring boot application. I use IntelliJ 13.

I want to launch my application in debug mode and debug it. I'm on Windows and I'd like to use shared memory. I would like to just be able to click the debug icon, or a single maven goal, and the application launches in debug mode and the IDE attaches the debugger. This is how I am used to debugging most of my java apps.

However, mixing spring-boot and IntelliJ seems to complicate things. IntelliJ seems to want to connect to the wrong process when I push the green "debug" button and I can't find a way to change the shared memory address that the green 'debug' button's functionality is determined to connect to.

The closest I've come is to add jvmoptions to the maven goal in pom.xml, and then if I add a Remote run configuration, IntelliJ lets me specify a shared memory address that matches what I wrote in the pom. This requires multiple clicks to launch the application and then debug it. It works, in a similar way that using notepad.exe to write code also works. Hence my question.

Is there a 1-step solution using shared memory?

Variation of this question: Debugging jsp with spring-boot and IntelliJ

However the question and answers are limited to using sockets.

Community
  • 1
  • 1
user1445967
  • 1,520
  • 4
  • 14
  • 30
  • ...if you have a working solution with sockets, why insist on shared memory? – radai Aug 08 '14 at 03:33
  • 1
    Maybe I'm doing it wrong but I just run (or debug) my `Application` class (the class containing the main method) from Intellij... Don't use maven or gradle to start the proces simply let Intellij do it. If you are building a deployable war just do it as you would normally deploy/run a war from intellij. Again don't use maven/gradle to run the project. – M. Deinum Aug 08 '14 at 06:33
  • 1
    What's wrong with simply running Debug on the main class? – geoand Aug 08 '14 at 12:18

2 Answers2

0

The problem was that IntelliJ was using the Maven goal spring-boot:run as the launch configuration, and trying to debug this causes the debugger to attach to the wrong process.

Setting a new launch configuration of type Application and pointing it at the project's class with the main() method resolves this issue.

Thanks to the commentors for suggesting that this was the way to go about it!

user1445967
  • 1,520
  • 4
  • 14
  • 30
0

A one click solution (tested on IntelliJ IDEA 14.0.1) using Sockets :

  • Open Run/Debug Configurations, Add a new Configuration of type Remote
  • On the Before Lauch panel, add a Run Maven Goal with the command line command:

spring-boot:run "-Drun.jvmArguments=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

The suspend=n option is important to avoid the Maven Goal to be locked waiting the debugger to connect.

After that you will be able to just lauch this debug task and your app will be launched and the debugger will be attached.