Spark: Embedded Jetty server refresh static files automatically

Created on 5 May 2016  路  4Comments  路  Source: perwendel/spark

Hi, is there a way to configure the jetty server embedded in spark to have a faster static file refresh interval? Currently I am having to restart my Java spark application each time in order for html and javascript changes to be reflected in the browser. Apologies if this has been asked before.

Feature request

Most helpful comment

Playe around with this hack a little, seems to work well: staticFiles.externalLocation(System.getProperty("user.dir") + "/src/main/resources/public");
This will tell Spark to look for files in the src folder instead of the target folder.

Only use this while developing

All 4 comments

You shouldn't have to restart the server. If you're using IntelliJ you can do Ctrl+F9 to make the project, which usually takes a second. Building this functionality into the framework itself sounds nice, but I'm not sure if it's possible.

Playe around with this hack a little, seems to work well: staticFiles.externalLocation(System.getProperty("user.dir") + "/src/main/resources/public");
This will tell Spark to look for files in the src folder instead of the target folder.

Only use this while developing

Hi, thanks for getting back to me, I really appreciate it as I am using spark for my uni dissertation project. I have tried that but it still doesnt want to serve the updated files. For now I have moved over to apache for serving up the files and jetty for the REST API. Thanks again though :-)

Hm. Working fine for me on both OSX and WIN. Are you using Spark 2.5?

Was this page helpful?
0 / 5 - 0 ratings