It should be possible to have a Spring Boot app continuously build (i.e. hot reload) by running gradle build --continuous
and gradle bootRun
in sequence.
I'm trying to modify the bootRun task in the gradle build file so that it calls the build task in continuous mode, but I can't seem to add arguments to it.
bootRun.dependsOn build
How can I get that build to run continuously?
This question and the corresponding answers are pretty interesting.
Short answer : you can't have the bootRun
task running with the continuous
option (if your app stays alive indefinitely)
But there is a hack by Stefan Crain :
To get it to live reload you need to have 2 terminals open.
gradle build --continuous
- build --continuous will keep satisfying the initial build request until stopped
gradle build --continuous --quiet & 2>1 >/dev/null
runs in the background, but you would miss the important build warnings/errors.gradle --stop
to stop watching.
gradle bootRun
- bootrun starts with spring-boot-devtools on classpath, which will detect changes and restart application.
I think it's what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With