【问题标题】:thymeleaf caching with spring boot带有弹簧靴的百里香叶缓存
【发布时间】: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


【解决方案1】:

万一其他人遇到这个问题,它是 IntelliJ 特有的:

我在启动配置下使用“Tomcat”模板。一旦我将其更改为“Spring Boot”配置模板,它就会按预期运行。

【讨论】:

  • 我有你提到的同样的问题,但我不知道你的回答是什么意思。我一般知道在哪里更改运行配置,但我不知道在哪里/如何将其从 Tomcat 更改为 Spring Boot 模板。它们都没有在模板下列出。有什么提示吗?
  • 没关系。我找到了this guide,对我来说效果很好。 :)
猜你喜欢
  • 2021-12-11
  • 1970-01-01
  • 1970-01-01
  • 2016-06-01
  • 2018-11-20
  • 1970-01-01
  • 2018-11-24
  • 2014-06-25
相关资源
最近更新 更多