SpringBoot opens hot deployment form development summary

Background: If you do not use hot deployment to develop, you will restart the service every time you modify the java code, which wastes time and affects development efficiency. Write an article below to summarize the hot deployment development.

 

Enter the topic === Open the hot deployment development steps:

1. Introduce maven dependency

		<!-- 热部署模块 -->
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-devtools</artifactId>
			<optional>true</optional> <!-- 这个需要为 true 热部署才有效 -->
		</dependency>

 

2. Check whether the automatic compilation function is turned on in the compilation tool, IDEA is not turned on by default, open the setting, find the compiler and check automatic compilation

 

3. Disable template engine caching in application.properties/yml

#禁用模版引擎缓存
spring.thymeleaf.cache=false

 

4. After configuring the above two steps, the project still cannot be automatically deployed or compiled automatically, because maven did not compile the project to the corresponding directory of the target. The last operation

ctrl+shift+alt+/ open, enter the registry, check this option

 

5. If you want to hot deploy the specified directory to improve efficiency, then

#添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**

Also note:

By default, the file modification in /META-INF/maven, /META-INF/resources, /resources, /static, /templates, /public will not restart the application, but will reload (devtools is embedded A LiveReload Server, when the resource changes, the browser refreshes)

Guess you like

Origin blog.csdn.net/qq_41055045/article/details/106223955