【发布时间】:2018-04-02 13:22:57
【问题描述】:
我发现很多很多关于使用 Thymeleaf 禁用模板缓存以进行开发的帖子,但我无法让它工作。我的堆栈:
- Spring Boot 1.5.7
- spring-boot-devtools
- 百里香
- IntelliJ IDEA Ultimate 2017.2
我不需要自动重建:我已将 IntelliJ 中的“重建”命令映射到 ⌘-S,这对于热交换 Java 类非常有用。但是,css 和 html 模板仍然只有在我重新启动服务器时才会显示更改。
我的 application.properties:
spring.thymeleaf.prefix=/WEB-INF/templates/
spring.thymeleaf.cache=false
我试过了:
• 将模板文件夹移动到 webapp/resources(并调整模板根目录)
• 连接不同类型的模板解析器(例如 FileTemplateResolver)
• 在@Configuration 文件中配置模板解析器,而不是让Spring Boot 使用默认值和application.properties 值
以下是我的 pom.xml 文件中的相关条目:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
这里有什么我遗漏的吗?
【问题讨论】:
-
编辑模板后,请同时使用
CTRL+F9制作项目。 -
@AbdullahKhan 感谢您的快速响应:实际上,这是我在 Mac 上映射到 ⌘-S 的命令(在我的原始帖子中,我不准确地将其称为“重建”),它没有任何效果。 ..仍然需要重新启动服务器。
标签: spring-boot intellij-idea thymeleaf