Thymeleaf 缓存设置为 false 不起作用

Vih*_*tla 4 spring thymeleaf spring-boot

我有一个正在开发的 Spring 应用程序。项目配置如下:

  • spring-dev-tools 依赖是 Maven 依赖之一
  • thymeleaf依赖是通过spring-boot-starter添加的,即org.springframework.boot:spring-boot-starter-thymeleaf
  • 我已明确禁用模板缓存spring.thymeleaf.cache=false
  • src/main/resources文件夹在我的 IntelliJ IDEA 项目中被标记为资源。

我正在使用 IntelliJ IDEA 项目来运行该应用程序。当我运行应用程序时,我可以在控制台输出中看到:LiveReload server is running on port 35729
虽然我的所有配置似乎都是正确的,但正在运行的应用程序并未加载我在运行时对模板所做的任何更改。

pab*_*ros 7

如果您正在使用Spring Tool Suite 4,则需要在您的中执行以下操作以application.properties禁用:cacheThymeleaf

spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/
Run Code Online (Sandbox Code Playgroud)

增加spring.thymeleaf.prefix价值对我有用。

有关该解决方案的更多信息:

https://github.com/spring-projects/spring-boot/issues/34#issuecomment-316295791