There are five hot deployment modes of spring boot, so you don’t have to restart!

Time:2021-11-29

There are five hot deployment modes of spring boot, so you don't have to restart!

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

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

1. Template hot deployment

In spring boot, the page cache of the template engine is enabled by default. If the content of the page is modified, the refreshed page will not get the modified page. Therefore, we can turn off the cache of the template engine in application.properties, as follows:

Configuration of thymeleaf:

spring.thymeleaf.cache=false

FreeMarker configuration:

spring.freemarker.cache=false

Groovy configuration:

spring.groovy.template.cache=false

Velocity configuration:

spring.velocity.cache=false

2. Hot deployment using debug mode

This method is the simplest and fastest hot deployment method. The debug mode is used when running the system without installing any plug-ins. However, the configuration file and method name are not changed, and classes and methods are added for hot deployment. The scope of use is limited.

3、spring-boot-devtools

Add the spring boot devtools dependency to the spring boot project to realize the hot deployment of pages 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 change of the system, including modification of configuration file and change of method name, can be covered, but the sequelae is also very obvious. It is realized by using the restart strategy after file change, which mainly saves the time for us to click restart manually, improves the effectiveness, and will be slightly worse in experience.

Spring boot devtools turns off the template cache by default. If you use this method, you don’t need to turn off the template cache separately.

4、Spring Loaded

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

5、JRebel

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

If there are any errors or other problems, you are welcome to leave comments and corrections. If you are helpful, welcome to like + forward and share.

Welcome to the official account of the brother of migrant workers:Migrant workers’ road to technology
There are five hot deployment modes of spring boot, so you don't have to restart!

Recommended Today

On the mutation mechanism of Clickhouse (with source code analysis)

Recently studied a bit of CH code.I found an interesting word, mutation.The word Google has the meaning of mutation, but more relevant articles translate this as “revision”. The previous article analyzed background_ pool_ Size parameter.This parameter is related to the background asynchronous worker pool merge.The asynchronous merge and mutation work in Clickhouse kernel is completed […]