Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Latest commit

 

History

History
61 lines (49 loc) · 2.5 KB

setup-live-reload-springboot.asciidoc

File metadata and controls

61 lines (49 loc) · 2.5 KB
title order layout
Setting Up Live Reload using Spring Boot
2
page

Setting Up Live Reload using Spring Boot

If your Vaadin application uses Spring Boot, Live Reload can make use of Spring Boot Developer tools to automatically restart whenever files on the classpath change. More information about Spring Boot Automatic Restart and other developer tools is available at https://docs.spring.io/spring-boot/docs/2.2.0.RELEASE/reference/html/using-spring-boot.html#using-boot-devtools.

Step-by-step guide

  1. Verify if spring-boot-devtools is added as a dependency in your Vaadin application pom.xml. If not add it like so:

    <dependencies>
        ...
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>
  2. Run the application using mvn spring-boot:run or by running the Application class directly from your IDE

  3. Navigate to your Vaadin application on the browser, make some changes, recompile and the browser will reload automatically

    Note

    If you have some browser extension that triggers Spring Dev Tools reloads on the browser, we recommend disabling such tools as Vaadin handles reloads automatically once the server has restarted. Having these enabled when using Live Reload might cause unexpected behaviour.

Additional configuration

  • If after changing code and reloading the browser page, you cannot access a view in your application, but instead get an error page with message like Could not navigate to …​ or Error creating bean with name …​, you need to adjust the dev tools configuration to ensure code changes get picked up. You can do this by adding the following lines to your application.properties file:

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

Which changes work?

Basically all Java code modifications are applied automatically: - changes in the internal application logic - routes modification (such as add a new view (route), update the route path, remove a view) - changes made to custom components (PolymerTemplate subclasses): add/change/remove

During those changes the session is preserved.

Changes that require application restart

All changes described above applied automatically only assuming you don’t add new dependencies to the project. The modifications which rely anyhow on updated classpath dependencies require an application restart.