Thymeleaf热部署 实现更改页面不重启

1、修改pom文件,添加依赖

 1 <dependency>
 2    <groupId>org.springframework.boot</groupId>
 3    <artifactId>spring-boot-starter-thymeleaf</artifactId>
 4 </dependency>
 5 
 6 <dependency>
 7    <groupId>nekohtml</groupId>
 8    <artifactId>nekohtml</artifactId>
 9    <version>1.9.6.2</version>
10 </dependency>

说明:使用springboot的thymeleaf模板时默认会对HTML进行严格的检查,导致当你的标签没有闭合时就会通不过。nekohtml这个依赖可以解决这一问题

2、简单配置一下:

spring.thymeleaf.cache=false
spring.thymeleaf.mode = LEGACYHTML5

说明:

第一行配置是清除缓存,实现热部署。也就是修改了html后不用重启,刷新页面就能看到效果。不过这儿特别强调一下,修改完html后一定要ctrl+f9重新build一下。再回到浏览器刷新,就能看到效果了,就这个花了我一个小时去找答案。

第二行配置是回避HTML进行严格的检查的配置,当然你需要提前引入nekohtml依赖。

注意:引入

Thymeleaf

依赖后,可以不用在application.properties里配置,默认会在resource.templates里找 。html的页面

原地址: https://blog.csdn.net/qq_22212003/article/details/80329896

<dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
   <groupId>nekohtml</groupId>
   <artifactId>nekohtml</artifactId>
   <version>1.9.6.2</version>
</dependency>
原文地址:https://www.cnblogs.com/The-second/p/12597099.html