idea的springboot修改代码无需重启(热部署)

1.pom.xml 配置文件


       org.springframework.boot
       spring-boot-devtools
       true 
 

2.application.properties

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

默认情况下,/META-INF/maven,/META-INF/resources,/resources,/static,/templates,/public这些文件夹下的文件修改不会使应用重启,但是会重新加载(devtools内嵌了一个LiveReload Server,当资源发生改变时,浏览器刷新)

如果使用Thymeleaf模板引擎,需要把模板默认缓存设置为false

spring.thymeleaf.cache=false

上面操作正确后还是没有效果,需要检查IDEA配置中有没有打开自动编译

idea的springboot修改代码无需重启(热部署)_第1张图片

你可能感兴趣的:(springboot,java基础)