Spring boot five hot deployment methods, no longer need to restart!

Time:2020-10-1

Spring boot five hot deployment methods, no longer need to restart!

Source: ruoli x my.oschina.net/ruoli/blog/1590148

  • 1. Template hot deployment
  • 2. Using debug mode to realize hot deployment
  • 3、spring-boot-devtools
  • 4、Spring Loaded
  • 5、JRebel

1. Template hot deployment

In spring boot, the page of the template engine is enabled for caching by default. If the content of the page is modified, the page cannot be refreshed after refreshing. Therefore, we can use the application.properties To turn off the cache of the template engine, as follows:

Configuration of thymeleaf:

spring.thymeleaf.cache=false

FreeMarker configuration:

spring.freemarker.cache=false

Configuration of groovy:

spring.groovy.template.cache=false

Velocity configuration:

spring.velocity.cache=false

2. Using debug mode to realize hot deployment

This method is the simplest and fastest way of hot deployment. When running the system, debug mode is used without installing any plug-ins. However, there is no need to change the configuration file, method name, add classes and methods for hot deployment, and the scope of use is limited.

3、spring-boot-devtools

Add spring boot devtools dependency in spring boot project to realize hot deployment of page and code.

As follows:

<dependency>  <groupId>org.springframework.boot</groupId>  <artifactId>spring-boot-devtools</artifactId></dependency>

This method is characterized by a wide range of functions. Any changes to the system, including configuration file modification and method name change, can be covered. However, the sequelae is also very obvious. It is realized by using the strategy of restarting after file changes. It mainly saves the time for us to click restart manually, improves the effectiveness, and is slightly worse in experience.

Spring boot devtools turns off the template cache by default. If you use this method, you do not need to configure it separately to turn off the template cache.

4、Spring Loaded

This method is similar to debug mode and has limited scope of application. However, it does not depend on the startup of debug mode. Starting through the spring loaded library file, real-time hot deployment can be carried out in normal mode. This needs to be configured in run configuration.

5、JRebel

Jrebel is the best hot deployment tool for java development, which provides excellent support for spring boot. Jrebel is a paid software with a trial period of 14 days. Can be installed directly through plug-ins.

If there are any errors or other problems, you are welcome to comment and correct. If you have any help, please click like + forward to share.

Welcome to the official account of the brother of migrant workers:Migrant workers’ technology road
Spring boot five hot deployment methods, no longer need to restart!