3

I have created an sbt project to learn simple crud operation using akka-http. First I added simple routes to check if it is working or not.

By running sbt run command, I found that it runs locally without any error.

But when I make some changes to the project (for example: Adding println statement to the running code) it does not auto compiling. Every time I have to exit (ctrl+c) the running sbt. And again run to see the updated code.

So my question is that how to auto compile sbt project while running the project.

Thank you.

laughedelic
  • 6,230
  • 1
  • 32
  • 41
md samual
  • 305
  • 3
  • 15

1 Answers1

5

As far as I know, it's not handled by default by sbt, but there's a plugin for that: sbt-revolver. It will trigger the restart of your application as soon as there are any changes in the source code of your application.

Just add

addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")

in your build.sbt and then start the app with:

sbt ~reStart
Krzysztof Atłasik
  • 21,985
  • 6
  • 54
  • 76
  • I found that sbt-revolver was already there in plugin.sbt file. It is now auto compiling using ~reStart. Thanks – md samual Jun 25 '21 at 11:19
  • You can approve and/or upvote the answer if you found it helpful. – Krzysztof Atłasik Jun 25 '21 at 11:39
  • If you are using play framework, in that case you don't need sbt-revolver. sbt launches Play with the auto-reload feature enabled. When you make a request, Play will automatically recompile and restart your server if any files have changed. If needed the application will restart automatically. – md samual Nov 09 '22 at 06:17
  • https://www.playframework.com/documentation/2.8.x/PlayConsole#Development-mode – md samual Nov 09 '22 at 06:17