title | order | layout |
---|---|---|
Setting Up Live Reload using Spring Boot |
2 |
page |
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.
-
Verify if
spring-boot-devtools
is added as a dependency in your Vaadin applicationpom.xml
. If not add it like so:<dependencies> ... <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies>
-
Run the application using
mvn spring-boot:run
or by running theApplication
class directly from your IDE -
Navigate to your Vaadin application on the browser, make some changes, recompile and the browser will reload automatically
NoteIf 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.
-
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 …
orError 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 yourapplication.properties
file:
spring.devtools.restart.poll-interval=2s spring.devtools.restart.quiet-period=1s
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.