2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
What is hot deployment? Hot deployment means that during the running of an application, there is no need to stop the entire application or restart it.server, you can deploy new code, resources or configuration files and make them take effect immediately. This deployment method helps improve development efficiency and system availability.
With hot deployment, when a part of the code is modified, the incremental content can be automatically compiled and deployed without restarting the project. You only need to refresh the browser to see the effect of the updated code modification. This greatly improves development efficiency and simplifies waiting time.
How to implement hot deployment? In IntelliJ IDEA, there are several common ways to implement hot deployment:
The ones used in this article areSpring Boot DevTools。The IDEA software version is 2023.2.3.
Step 1: Introducing dependencies
Introduce the spring-boot-devtools dependency in the pom.xml file in the Maven project.
Code language: html
copy
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-devtools</artifactId>
- <scope>runtime</scope>
- <optional>true</optional>
- </dependency>
Step 2: Write configuration
Write the configuration in the yml file.
Code language: html
copy
- spring:
- devtools:
- restart:
- enabled: true
Step 3: Set up the project automatic compilation function (static compilation)
1. Hot deploy the current project
Right click: File --> Settings --> Build,Exec.... --> compiler --> check Build project automatically. As shown in the figure.
Build project automatically: Automatically package the project and click Apply.
2. Hot deploy the newly created project (optional)
Right click: File --> New Projects Setup --> Settings for New Projects --> Settings --> Build,Exec.... --> compiler --> 勾选Build project automatically。as the picture shows.
The remaining steps are the same as above, so I won’t post screenshots here.
Step 4: Enable hot deployment during operation (dynamic compilation)
Right click: File --> Settings --> Advanced Settings --> Check Allow auto-make to start even.....
Click Apply.
After changing the project code, return to the page and refresh it to see the effect of hot deployment.