- Spring Boot
Live Reload works seamlessly in development mode using HotswapAgent for runtime class and resource redefinition. We suggest running your Vaadin project with TravaOpenJDK DCEVM, version 11.0.7+2 or later, which includes HotswapAgent with full Live Reload support. Setup is in most cases as easy as downloading the JDK and configuring your IDE to use it. If you want to know more about the features of HotswapAgent, the documentation in the HotswapAgent webpage is a good resource.
Download and unpack the latest version of DCEVM JDK, add the JDK to your IDE, and set your project / run configuration to use it. Alternatively set
JAVA_HOMEto its location.
In DCEVM 11.0.9 and later, HotswapAgent is disabled by default and needs the JVM parameter
-XX:HotswapAgent=fatjarto work with Vaadin. Depending on your project technology stack, you may also want to apply additional configuration.
Using your IDE’s debug command, start the Vaadin application in development mode.
Navigate to a view in your application, edit any Java file in the project, recompile, and the browser will automatically reload the page with the changes.
HotswapAgent swaps in code changes automatically only when the JVM is running in debug mode. The
spring-boot:runby default forks a separate JVM without debugger attached, meaning that HotswapAgent will not work. You can disable forked mode by adding
<fork>false</fork>to the plugin’s
To hot swap code when the JVM is not in debug mode, you can add the line
hotswap-agent.properties(in Spring Boot projects), or add the JVM parameter
JAVA_HOMEis the Java home of the TravaOpenJDK installation. Explicitly enabling automatic hotswapping may also be required with some older IDEs (such as NetBeans).
When using the Jetty Maven plugin together with HotswapAgent, ensure automatic restart is disabled (omit or set
<scanIntervalSeconds>to a value of
The Live Reload quiet time (milliseconds since last Java change before refreshing the browser) can be adjusted with the parameter
hotswap-agent.properties. The default is 1000 ms. Increase this value if you notice the browser refreshing before modified Java files have been fully compiled.
IntelliJ IDEA: avoid using the
Build project automaticallyand
compiler.automake.allow.when.app.runningoptions simultaneously, since this may trigger automatic reload before classes are hotswapped properly.
Since the server does not restart, modifications to startup listeners and code that connects frontend and backend components, such as adding a new
LitTemplateclass, are not reflected. Modifications to routes are, however, picked up.
@PreserveOnRefresh, view instances are reused when reloaded in the browser; hence, hotpatched changes to the view constructor will not be reflected until the view is opened in another browser window or tab.
The Vaadin plugin included in the bundled HotswapAgent (1.4.1) does not work with servers that use application class loaders, for instance WildFly, TomEE or Payara. This bug is fixed in a prerelease version of HotswapAgent. To use it, download the JAR and pass the JVM parameter
-XX:+DisableHotswapAgent -javaagent:<path/to/hotswap-agent.jar>to replace the bundled HotswapAgent with the fixed version.