Live Reload

The Jetty Maven plugin with the scanIntervalSeconds configuration set to a positive value performs complete application restart when the given number of seconds have elapsed since the last Java change. For instance:

  1. <plugins>
  2. <plugin>
  3. <groupId>org.eclipse.jetty</groupId>
  4. <artifactId>jetty-maven-plugin</artifactId>
  5. <version>9.4.36.v20210114</version>
  6. <configuration>
  7. <scanIntervalSeconds>2</scanIntervalSeconds>
  8. </configuration>
  9. </plugin>
  10. <!-- more plugins -->
  11. </plugins>
Note
Recommended minimum version

Jetty Maven Plugin versions before 9.4.36.v20210114 have known issues:

  • RouteNotFoundException when trying to reload Java changes automatically

  • A reload loop on Windows when setting scanIntervalSeconds to a small positive value

Since the plugin performs a full server restart, all Java changes are picked up. This includes modifications to server startup listeners as well as changes to code that connects frontend and backend components, such as adding a new LitTemplate class, or adding a new CSS import and using it in Java via @CssImport annotation.

However, the session is not preserved during the restart.

Updated 2021-03-08  Edit this article