Introduction to hot deployment
Spring Boot The developer is Spring Boot A hot deployment is provided in the project (spring-boot-devtools) modular , Support the hot deployment of the project ( After modifying some resources, it can be refreshed without restarting the service ), To improve development efficiency . The bottom layer is actually implemented with the help of two class loaders , A class loader loads invariant classes , Another class loader loads classes that may change , To provide class hot deployment performance .
Hot deployment environment initialization
The demonstration of this hot deployment is in IDEA Implementation in development , Other tools can learn by themselves through search engines .
IDEA Start automatic compilation , As shown in the figure :
IDEA Start the registration window in the tool ( Press ctrl+shift+alt+/), As shown in the figure :
Select compile build configuration , As shown in the figure :
Hot deployment is applied in projects
In projects that require hot deployment or module Add the following dependency :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
Rely on downloading , It can be restarted reload project , And then when we changed src/main/java In the catalog java File or modify src/main/resources The configuration file in the directory , You'll be rebooted by default web The server , But the test class or html Files don't automatically restart and deploy .
summary (summary)
This section is right springboot The hot deployment in the project is analyzed and implemented , Sure idea Practice the whole process in the tool .