Table of contents
1. The benefits of setting up hot deployment
2. Disadvantages of setting hot deployment
3. Set up the process of hot deployment
4. Turn off the hot deployment function
1. The benefits of setting up hot deployment
The main benefit of Spring Boot hot deployment is to improve development efficiency and experience during the development process. It allows developers to quickly and automatically reload the application without manually restarting the application after modifying the code, reducing the modification-build-restart time and number of operations. This enables faster feedback loops and reduces development costs and error rates. At the same time, hot deployment can also reduce system downtime in the production environment and improve system availability.
2. Disadvantages of setting hot deployment
Although Spring Boot hot deployment can improve development efficiency and experience, there are some limitations and potential risks. Here are some possible downsides:
-
Hot deployment introduces some overhead in performance and memory consumption, as the application needs to be constantly reloaded and initialized.
-
In some scenarios, hot deployment may cause confusion in the state of the code, such as class loader problems, resource sharing problems, and so on.
-
Hot deployment depends on specific IDEs, plugins, and configurations. If used incorrectly, it may cause adverse effects, such as lag, failure, inexplicable bugs, and so on.
-
Differences in various operating systems or development environment versions, as well as multi-threading or other concurrent processing methods, may have certain impacts and limitations on the effect of hot deployment.
Therefore, when choosing whether to adopt Spring Boot hot deployment, it is necessary to balance the actual needs and feasibility, and avoid aimlessly following or abusing.
3. Set up the process of hot deployment
Implementing Spring Boot hot deployment usually requires the following steps:
1. Add Spring Boot DevTools dependencies: Add the following dependencies in the pom.xml file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
2. Enable automatic reloading: add the following configuration in the application.properties or .yml file
spring.devtools.restart.enabled=true
3. (Optional) Exclude hot deployment of resource files and static files: add the following configuration to the application.properties or .yml file
spring.devtools.restart.exclude=static/**,public/**
For versions below 4.2020, hold down ctrl+shift+alt+/ to find Registry and click
2020 and above, you can set it in File->setting->advanced Settings
In this way, a simple hot deployment is started
4. Turn off the hot deployment function
1. Modify application.properties
Set the above enabled to false
2. The disabling of hot deployment has priority, so first look at how the priority is divided:
You can see that the first method is set on priority 3. If we want to change to priority 6, we can do this:
@SpringBootApplication
public class Springboot12HotDisplayApplication {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled","false");
SpringApplication.run(Springboot12HotDisplayApplication.class, args);
}
}