Couple Gradle's continuous build feature with the recently-released Spring Boot 1.3's DevTools, and you've got continuous auto-restarting.
With the recent release of Spring Boot 1.3, there is a new dependency in town: Spring Boot DevTools. Which enables us to automatically restart Spring Boot applications if some classes in the class path have changed.
This is quite handy for local development, but still, you need to trigger the build phase to recompile the class. In this case, we can use Gradle's continuous build feature and automatically rebuild our project. Spring Boot DevTools will pick up the changes and restart application.
One way to do this is to add the necessary dependencies to your build.gradle
. In this example, the DevTool dependency is added only when we run the bootRun task (devconfiguration). There are other features of DevTool that can be useful during development, and at other times as well. So it's up to you on how you want to organize your project.
After this, we just need to open two terminals:
- At the first terminal, start Gradle build as a continuous task:
gradle build --continuous
- At the second terminal, start the Gradle bootRun task:
gradle bootRun
A working example can be found here.
Spring boot gradle hello world example
Spring boot fat jar gradle
Spring boot multi module gradle
Gradle build jar
Gradle bootrun
Spring boot war gradle
![Bootrun Bootrun](/uploads/1/1/9/7/119765369/386029013.png)