我正在开发一个 Spring 应用程序。 项目配置如下:
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
如果您正在使用
Spring Tool Suite 4
,则需要在 application.properties
中执行以下操作以禁用 cache
中的 Thymeleaf
:
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=file:src/main/resources/templates/
添加
spring.thymeleaf.prefix
值对我有用。
有关解决方案的更多信息:
https://github.com/spring-projects/spring-boot/issues/34#issuecomment-316295791
LiveReload 服务器仅在类路径上的文件之一被修改时加载任何更改Spring Doc。
虽然我有资源,包含模板文件夹的文件夹,但在类路径上,对模板文件夹中的 html 文件的更改不会反映在正在运行的应用程序中。
对我有用的是将
src/main/resources/templates
添加到类路径,即在 IntelliJ 中标记为资源
谢谢
对我来说添加这两个属性是有效的:
spring.thymeleaf.cache=false
spring.devtools.restart.additional-paths=file:src/main/resources/templates/
我使用的是STS 4.20.1