score:93
After you run gradle bootRun --debug-jvm
the application is suspended until you connect your debugger to the port it is listening on (port 5005).
score:-1
Define an executes a Java application in a child process.
task executeApp() {
doFirst {
println "Executing java app from Gradle..."
javaexec {
main = "com.mymain"
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=30000"]
}
}
}
Set your breakpoints in the java code. After execute the Gradle task.For example in Windows:
.\gradlew.bat executeApp
The task waits until you attach the debugger. For example in Netbeans go to Debug->Attach debugger , set 30000 on port Field.
score:2
For people hitting this via Google and wondering how to enable Spring's debug mode (normally done by java -jar app.jar --debug
) and using Gradle, here is how. This passes --debug
to the main class which is how you turn on Spring Boot's debug mode which logs autoconfig classes among other things.
./gradlew bootRun --args='--debug'
score:4
I personally prefer going under Gradle tasks
and right-clicking on the bootRun
. This is useful in the IDE compared to the terminal.
score:5
For build.gradle.kts
file you can also simply use below:
tasks.withType<BootRun> {
jvmArgs = listOf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:32323")
}
score:39
As a response to dankdirkd's answer above: (compare)
gradle bootRun --debug-jvm
will make the gradle build run in debug mode. That probably is not what you want. What you want to achieve is that the springBoot task starts your application in debug mode.
The spring boot task extends the gradle JavaExec task. You can configure the bootRun task in your build.gradle file to add a debug configuration like this:
bootRun {
jvmArgs=["-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=32323"]
}
For the build.gradle.kts this would look like this (with suspend mode disabled):
tasks {
val bootRun by getting(BootRun::class) {
jvmArgs=listOf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=32323")
}
}
If your server is within a cloud and you want to debug from local machine, you need to make sure that it allows connections from outside. Use below configuration in that case
tasks {
val bootRun by getting(BootRun::class) {
jvmArgs=listOf("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:32323")
}
}
Note that the address is now 0.0.0.0:port
instead of just port
Source: stackoverflow.com
Related Query
- how to debug spring application with gradle
- How to debug Spring Boot application with Eclipse?
- How to solve "Secure storage was unable to save the master password" in Eclipse CDT remote application with SSH password debug connection?
- how to debug java web application in eclips with weblogic server
- How to profile a java application in debug mode with JProfiler
- How to run and debug C++ application in Eclipse that's started with a script?
- How can I debug Web Application with Eclipse?
- How to remote debug two spring boot applications running in the same container with the same codebase but with different profiles?
- How to debug Java Desktop Application with Ant Script?
- Debug Gradle application with instrumented files
- How to use an existing database with an Android application
- How to Debug Android application line by line using Eclipse?
- How to run Spring Boot web application in Eclipse itself?
- How to enable debug on my JUnit through Gradle test task
- how to debug application as root in eclipse in Ubuntu?
- How can I create Spring web project with Maven in Eclipse?
- How to start with STS and Gradle
- How to run spring boot application both as a web application as well as a command line application?
- c++: How to debug a C++ application compiled using the "Microsoft Visual C++" toolchain in eclipse?
- How do i debug a web application running on jetty in eclipse?
- How to use JavaFX Preloader with stand-alone application in Eclipse?
- How to debug tests with Play! 2.0
- How does Eclipse debug code in an application server?
- How do I create a Spring Boot Starter Project in Eclipse that is properly configured with a Run Configuration?
- How can I check on debug symbol status with Eclipse?
- How to debug CUDA using eclipse Nsight with only one GPU
- How to debug Flask with PyDev?
- On Linux, Debugging a C++ application with gdb in Eclipse CDT, how to input something to stdin?
- How to configure Eclipse with Gradle in multi project?
- How to configure jboss application server with eclipse IDE
More Query from same tag
- Reset Eclipse Screen to Default When First Installed
- Can't install Android plugin for Eclipse on MacOS X (Leopard)
- Application runs on Device but crashes on Emulator?
- How do I get Logcat for multiple devices running at the same time in Eclipse
- Working Set "Other Projects" in Eclipse Juno gone?
- Move a web app project from eclipse to tomcat standalone
- after starting eclipse my phone (htc desire) disconnects form my pc
- Liferay Service Builder Error
- Can I use C++ or Python in Eclipse plugin?
- Eclipse release heap back to system
- Debugging cocos 2d-x android project with ndk
- How do I merge two procedures into one?
- Is it possible to refactor package without corrupting AndroidManifest XML?
- Send App to App push notification in android using parse.com
- Why does Subclipse only work in some Ecliplse workspaces and not others?
- JUnit 4 test case passes when debugged but fails when ran
- Android noClassDefFound error with class reference in Eclipse?
- javax.servlet.ServletException: File "/WEB-INF/include/httpbase.jsp" not found
- How to test connectivity to ports
- Hints don't show up
- What does 'x' mark on the icons in package explorer in eclipse mean?
- Unable to Install ADT in Win7 64 bit
- Disable an eclipse plugin that causes a conflict with a plugin in my Feature
- cannot open Eclipse editor anymore
- How to identify the eclipse view get closed or not?
- Where are the SQL development tools for the Eclipse IDE and Spring Tools Suite? Why are they seemingly unavailable in their marketplaces?
- Getting error referencing an object from a different class in Java
- Eclipse function/plugin that finds corresponding junit class?
- Egit working directory vs. projects in Eclipse
- How to create an EAR file for an existing Maven Project