Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot bootRun with continuous build

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?

like image 904
David Wadge Avatar asked Aug 30 '18 08:08

David Wadge


1 Answers

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.

  1. 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.
  2. 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.

like image 60
ToYonos Avatar answered Sep 22 '22 13:09

ToYonos