问题
For some reason when i run my Spring application from intellij some task is not being executed because of which my stub server responds with a error.So i tried to start it through a pre-written go script in my project and it worked. But now attaching debugger becomes a problem because i have started my application from terminal.
I tried doing a remote debug by setting a remote configuration in intellij and setting the port as 8000 but i keep getting the error "Connection refused"
Below is the remote configuration screenshot: Remote config screenshot
Is this the correct approach to attach debugger for an app started through terminal?
Command to start in debug mode:
gradle bootRun
-Dagentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8080
回答1:
The alternative and easier way is opening the Run anything window (ctrl/command + shift + A) and then searching for attach debugger action. IntelliJ will try to find any processes that have debugger attached, and will display a list from which you can choose which process to attach to.
Provided that you get java.lang.module.FindException, you might also try to run gradle bootJar and then run the generated jar (in build/libs directory) file by
java "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8080" --add-exports java.base/jdk.hotspot.agent=ALL-UNNAMED -jar my_jar.jar
Please also note that finding a way to tell gradle to run your jar (in bootRun task) correctly is the more correct way.
来源:https://stackoverflow.com/questions/58581547/debugger-port-not-opening