Hot deployment with springboot



In the actual development process, every time you modify the code, you have to restart the project and re deploy it. For some large applications, the restart time costs a lot of time. For a back-end developer, the restart process is really hard. In the field of java development, hot deployment has always been a difficult problem to solve. The current Java virtual machine can only realize the hot deployment of method body modification. For the structure modification of the whole class, it still needs to restart the virtual machine and reload the class to complete the update operation. Let's see how to implement hot deployment for simple class modification.


The deep principle is that two classloaders are used. One loads the classes that will not change (third-party jar package), and the other loads the classes that will change, which are called restart classloader. In this way, when the code changes, the original restart classloader will be discarded and a restart classloader will be created. Because there are fewer classes to load, So it achieves faster restart time.

Start configuration

Add dependencies to pom.xml

        <!-- Devtools hot deployment -- >



Configuration of devtools

Configure devtools in application. YML

      Enabled: true # set to enable hot deployment
      Additional paths: Src / main / Java # restart directory
      exclude: WEB-INF/**
    Cache: false # the page does not load the cache, and the modification takes effect immediately

Configuration in idea

When we modify the class file, idea will not compile automatically. We have to modify the idea settings.

  • (1)File-Settings-Compiler-Build Project automatically
  • (2) CTRL + Shift + Alt + /, select registry, and check compiler automake allow when app running

Hot deployment with springboot

Hot deployment with springboot

This work adoptsCC agreementReprint must indicate the author and the link of this article