Live Reload

For Vaadin application based on Spring Boot, Live Reload by default uses Spring Boot Developer Tools to automatically restart the server whenever classpath entries are updated.

The restart is faster than a manual restart, as it uses a customized class loader that reloads only the application’s own classes. All Java code modifications are applied, including changes in the internal application logic, route modification (adding / removing / updating routes), and changes made to custom components (PolymerTemplate subclasses). The session is also preserved during the restart.

Step-by-Step Guide

  1. Ensure that spring-boot-devtools is a dependency in the application’s pom.xml:

    Show code

    XML

    Expand code

    1. <dependencies>
    2. ...
    3. <dependency>
    4. <groupId>org.springframework.boot</groupId>
    5. <artifactId>spring-boot-devtools</artifactId>
    6. <optional>true</optional>
    7. </dependency>
    8. </dependencies>
  2. Run the application using mvn spring-boot:run (requires forking the JVM, which is the default mode) or via the Application class.

  3. Open the application in the browser, make some Java code changes, recompile, and the browser will refresh automatically.

    Note
    Disable other Spring Developer Tools related browser extensions
    Uninstall or disable any other browser extensions that refresh on Spring Developer Tools reload. As the Vaadin client also refreshes, having both active might lead to unexpected behaviour.

Additional Configuration

If during server restart you notice spurious errors like Could not navigate to …​ or Error creating bean with name …​, or you frequently see multiple restarts from a single code change, the problem may be file monitoring triggering the restart prematurely, before all updated files have been written. The polling interval and quiet time can be configured in the application.properties file:

Show code

Expand code

  1. spring.devtools.restart.poll-interval=2s
  2. spring.devtools.restart.quiet-period=1s

Higher values improve stability at the cost of a higher-latency restart cycle.

Limitations

  • Modifications which rely on updated classpath dependencies require a full application restart.

  • The Vaadin client connects from the browser to the Spring Boot Live Reload server default port (35729). The port number to use cannot be changed in the client currently.