【Spring Boot教程】(十五):开启Spring Boot的devtools热部署

热部署就是在不重启Spring Boot项目的情况下,让我们的更改生效。这样在启动项目的时候会创建两个类加载器,dev-tools是通过两个类加载器实现热部署的,更改后会由空闲的进行编译,然后会进行类加载器的切换,空闲的替换正在工作的。甚至不用点小锤子

依赖:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

在idea中设置支持自动编译

# 开启自动编译
	Preferences-->Build,Execution,Development-->Compiler-->勾选Build project automatically

# 开启允许在运行过程中修改文件
	ctrl+alt+shift+/---->选择Registry---->勾选compiler.automake.allow.when.app.running

关闭thymeleaf缓存

springboot.thymeleaf.cache=false

猜你喜欢

转载自blog.csdn.net/m0_46521785/article/details/114924213