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

Latest commit

 

History

History
60 lines (52 loc) · 2.35 KB

spring-boot-devtools.md

File metadata and controls

60 lines (52 loc) · 2.35 KB

About Spring Boot DevTools

The DevTool package - Developer Tool - is used for developing Spring Boot applications. This package will pick up any changes and restart the application.

DevTool Features:

  • Automatic Restarts

    • Server-side changes are automatically implemented with server restart
    • Handled by property spring.devtools.restart.enabled.
    • The DevTool will always need to monitor class path in order to trigger restart.
    • Upon restarting, class loader is thrown away and reloaded.
    • There are two class loaders:
      • base ClassLoader
      • restart ClassLoader
    • Mostly required in mircoservice applications.
    • Works well with LiveReload.
  • LiveReload

    • An embedded server which allows the application to automatically trigger a browser refresh whenever there are changes.
    • Handled by property spring.devtools.livereload.enabled.
    • Also known as auto-refresh.
    • Works for the following paths:
      • /resources
      • /templates
      • /static
      • /public
      • /META-INF/maven
      • /META-INF/resources
  • Property Defaults

    • Web application package (Thymeleaf) has configuration to disable caching.
    • Handled by property spring.thymeleaf.cache.
    • Disabling will allow us to make changes without having to restart the application.
  • Remote Debug Tunneling

    • Can tunnel Java Debug Wire Protocol over HTTP.
    • Can deploy application to Cloud Providers over port 80/443.
  • Remote Update and Restart

    • Supports application updates and restarts by monitoring local classpath for file changes.
    • The file changes are pushed to a remote server before restarting to apply changes.
    • This is used in combination with LiveReload.

Recommendation: User a TRIGGER file

If you plan to use DevTool, use a trigger file to trigger your restarts rather than whenever there are changes applied. Frequent restarts can cause downtime and also slow development due to increasing amount of restarts. A trigger file can be implemented by using the property spring.devtools.restart.trigger-file.

spring.devtools.restart.trigger-file=c:/user/home/eclipse-workspace/app-name/restart-trigger.txt  

Example (Maven Dependency):

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-devtools</artifactId>
  <version>2.3.4.RELEASE</version>
  <scope>runtime<scope >  
</dependency>