Live reload means automatically reloading the application in the browser after modifying its code, instead of manually restarting the server and refreshing the browser page.
In Vaadin projects, live reload is supported out of the box for front-end code changes, and for Java changes in Spring Boot projects. For the latter, it also integrates with popular third-party Java hotpatching tools.
Code in the application’s
frontend folder (JS/TS/CSS files) is monitored by
webpack-dev-server when running the application in development mode.
Adding, modifying or removing a file in this folder triggers recompilation of the front-end bundle and a subsequent browser reload.
On the Java side, live reload means first compiling the modified code, then updating the running server (either by restarting it or by hotpatching the runtime), and finally refreshing the browser. Live reload can use Spring Boot Developer Tools automatic server restart feature (enabled by default in Spring Boot-based Vaadin applications). It can also use two hotpatching tools: JRebel (commercial, for all Vaadin applications) and HotswapAgent (open-source, for all Vaadin applications). See the following sections for details on setting up the chosen technology:
Note that only one of these technologies should be configured in the project at a time, to avoid interference. In general, hotpatching is faster than automatic restarts and works best for small, incremental changes. Larger changes, such as class level modifications or changes to code that affect the whole application lifecycle (startup, shutdown, mapping between front-end and back-end components), usually require a server restart in any case.
As an alternative to live reload, the Jetty and TomEE Maven plugins facilitate automatic server restart on Java changes. These do not require installing third-party tools, but have the disadvantage that server restarts are slower and the browser will not refresh automatically.