Developing/Debugging a Gradle-built Spring Boot app in IntelliJ IDEA
What's the best way to develop a Spring Boot app build by Gradle when using IntelliJ IDEA?
The Spring Boot run/debug approach doesn't work because it doesn't run the app using 'bootRun', it runs the main class directly. As a result things like client JARs don't get picked up and the app doesn't start up successfully.
And when run as a Gradle task, the app starts up successfully but hot swapping of code doesn't work. Changes to code don't affect the running app.
At the moment the best solution I've found is to type 'gradle build --continuous' in one terminal window and 'gradle -DDEBUG=true bootRun' in another window. Then go to IntelliJ and 'Run -> Attach to local process'. Debugging works and changing files works. Unfortunately, it's not hot swapping, it physically restarts the Spring Boot app and console output isn't inside IntelliJ. But it's automatic so that's something.
Am I missing something or is this just the way things work now?
Please sign in to leave a comment.
Do you use WAR deployment? This is not interchangeable with "plain" Spring Boot run configurations by design.
No, stand-alone JAR file.
Do you invoke "bootRun" target using "Debug [appName] bootRun"? You should get a dialog asking whether to reload changed classes after invoking "Build", those changes are correctly picked up for me in my minimal sample project.
If I try to debug by running Gradle, here's the configuration screen:
Could you please create an issue in our bug tracker https://youtrack.jetbrains.com/issues/IDEA with a minimal sample project to reproduce?