添加依赖
<!--让顶目支持热更新-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional><!--这个需要为 true热部署才有效-->
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId >spring-boot-starter-web </artifactId>
</dependency>
<!-- spring-boot-starter-thymeleaf -->
<dependency >
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf </artifactId>
</dependency>
关闭Thymeleaf缓存
application.properties配置文件中添加:
spring.thymeleaf.cache=false
IDEA配置修改
打开自动编译:
配置1:
配置2:
注:如果低版本IDEA可能找不到配置2,可以快捷键Ctrl+Shift+Alt+/
验证
重新启动项目看到如下restaredMain即设置成功:(修改代码后刷新页面会获取到最新状态,可能有几秒延迟)
评论区