Table of contents
Manually set up hot deployment
Automatically start hot deployment
Hot deployment configuration range
hot deployment
Manually set up hot deployment
Import maven coordinates
<!--热部署依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
Every modification click build project
This is still a manual click (ctrl+F9), the complexity is the same as the direct redeployment.
About Hot Deployment
- Restart: custom-developed diam, including classes, pages, configuration files, etc., loading location restart class loader (used for hot deployment)
- Reload: jar package, loading location base class loader
Hot deployment only loads developer-defined resources, not jar resources
Automatically start hot deployment
1. Import hot deployment dependencies
<!--热部署依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2. Open the settings to find the compilation, find the option in the figure below and check it
3. Press and hold ctrl+shift+alt+/ to display the picture below, click Register to find the picture below and check it.
4. After that, whenever the idea content changes and loses focus for 3 seconds , it will automatically help you build the project.
Hot deployment configuration range
List of directories that do not trigger restart by default
- /META-INF/maven
- /META-INF/resource
- /resource
- /static
- /public
- /templates
Customization does not participate in hot deployment.
spring:
devtools:
restart:
# 设置不参与热部署的文件或文件夹public/**表示public文件夹下的所有
exclude: public/**,config/application.yml
Disable hot deployment
set up
spring:
devtools:
restart:
enabled: false
#false表示关闭
In this way, hot deployment can be turned off, but it is easy to set in the configuration file so that other high-level configuration files can overwrite each other, so we
property loading priority
Set high priority to disable hot deployment
//启动类
@SpringBootApplication
public class Springboot01Application {
public static void main(String[] args) {
System.setProperty("spring.devtools.restart.enabled","false" );
SpringApplication.run(Springboot01Application.class, args);
}
}