Spring - MVC - thymeleaf 缓存关闭
1. 概述
- spring 配合 thymeleaf 关闭页面缓存
2. 背景
最近复习 spring
找了本书叫 spring in action 5th
- 本人水平有限
- 书还写得那么难
调试中遇到了问题
- 问题1: 我每次改代码, 都要重启
- 问题2: 我每次改页面, 都要重启
因为 问题2 对我来说, 优先级最高, 我首先解决它
3. 环境
os
- win10
jdk
- 1.8
ide
- ida 2018.1
spring
- spring boot
- 2.1.7 release
- 组件
- thymeleaf
- starter-web
- devtool
- starter-test
- spring boot
browser
- firefox
- 70.0
- firefox
ref
- spring in action 5th
4. 问题
期望
- 在 ide 修改页面
- 在浏览器直接刷新, 就能看到页面调整
需要保证
- 浏览器的正确配置
- 浏览器
- 确保每次请求, 都是新鲜的页面
- 浏览器
- spring 和 thymeleaf 的正确配置
- spring
- 确保 thymeleaf 的修改能及时
- spring
- 浏览器的正确配置
5. 问题解决
浏览器
思路1: 每次访问后清空缓存
- 结果
- 否决
- 太麻烦了
- 否决
- 结果
思路2: 通过浏览器配置, 确保每次请求, 都是新页面
结果
- 这个方案不错
- 而且也有配置项可以做到
- 因为很顺利, 就不细说了, 照着配置一步步来就行
ref
thymeleaf
- 思路: 找到配置项, 配置一下就好了
结果
- 妈的找死我了
- 百度了好多, 都没用
千篇一律, 只有一条参数
spring.thymeleaf.cache=false
结果配置了根本不生效
这感觉太难受了, 真的想骂人
最后结果
- ref
Thymeleaf templates cache even when spring.template.cache: false
一个叫 oak1980 的丹麦老哥, 给了一个配置如下
# Templates reloading during development
spring.thymeleaf.prefix=file:src/main/resources/templates/
spring.thymeleaf.cache=false # Static resources reloading during development
spring.resources.static-locations=file:src/main/resources/static/
spring.resources.cache-period=0
按照这个老哥的做法, 配置终于生效
- ref
- 思路: 找到配置项, 配置一下就好了
ps
妈的为啥我百度的头几个, 没有一个把事说明白
- 大部分只给了 cache = false 的那条配置
- 其他提到 prefix 的, 还都把 prefix 注释了
- 配置的 ide, 组件, 版本也没有
- 找了好半天, 问题是这种都是调试常识之类的东西
spring 如何确认运行阶段生效了哪些配置项
- 这个找了半天, 也没找到
- 我总觉得可以...
Spring - MVC - thymeleaf 缓存关闭的更多相关文章
- Spring MVC + Thymeleaf
参考网址: https://www.cnblogs.com/litblank/p/7988689.html 一.简介 1.Thymeleaf 在有网络和无网络的环境下皆可运行,而且完全不需启动WEB应 ...
- 使用maven简单搭建Spring mvc + redis缓存
注:此文参考并整合了网上的文章 <spring缓存机制>:http://blog.csdn.net/sidongxue2/article/details/30516141 <配置 S ...
- 使用方法拦截机制在不修改原逻辑基础上为 spring MVC 工程添加 Redis 缓存
首先,相关文件:链接: https://pan.baidu.com/s/1H-D2M4RfXWnKzNLmsbqiQQ 密码: 5dzk 文件说明: redis-2.4.5-win32-win64.z ...
- A real ROCA using Bootstrap, jQuery, Thymeleaf, Spring HATEOAS and Spring MVC
http://www.tuicool.com/articles/ENfe2u https://github.com/tobiasflohre/movie-database What is the be ...
- Spring MVC视图层:thymeleaf vs. JSP
本文对比了同一Spring MVC工程中相同页面(一个订阅表单)分别采用Thymeleaf和JSP(包括JSP.JSTL.Spring tag lib)两种方式的实现. 本文的所有代码来自一个可运行的 ...
- Thymeleaf 3与Spring MVC 4 整合配置
Thymeleaf 3与Spring MVC 4 整合配置 Maven 依赖配置 Spring 相关依赖就不说了 <dependency> <groupId>org.thyme ...
- Spring MVC 5 + Thymeleaf 基于Java配置和注解配置
Spring MVC 5 + Thymeleaf 注解配置 Spring的配置方式一般为两种:XML配置和注解配置 Spring从3.0开始以后,推荐使用注解配置,这两种配置的优缺点说的人很多,我就不 ...
- 在Spring MVC和Spring Boot中使用thymeleaf模板
Spring MVC: POM: <!-- thymeleaf模板 --> <!-- https://mvnrepository.com/artifact/org.thymeleaf ...
- Spring MVC : Java模板引擎 Thymeleaf (二)
本文原计划直接介绍Thymeleaf的视图解析,但考虑到学习的方便,决定先构建一个spring-mvc. 以下的全部过程仅仅要一个记事本和JDK就够了. 第一步,使用maven构建一个web app. ...
随机推荐
- centos7搭建天兔
如果新系统尚未安装工具pip,可通过以下三步快速安装pip 1. yum -y install epel-release 2. yum -y ...
- Selenium3+python自动化009-iframe定位
iframe 一.frame:HTML页面中的一种框架,主要作用是在当前页面中指定区域显示另一页面元素: 二.操作Frame中的页面元素 定位元素: 1.id定位driver.switch_to.fr ...
- 自定义Ribbon客户端策略
说明 为了实现Ribbon细粒度的划分,让调用不同的微服务时采用不同的客户端负载均衡策略, 通常情况下我们会自定义配置策略. 本文以内容中心(content-center)调用户中心微服务(u ...
- eclipse下载更新可用的SDK 2018-11-12
懒人方法: mirrors.neusoft.edu.cn:80 操作步骤: 1. Android SDK Manager----Tools----Options-----Http Proxy Serv ...
- 线段树的树状数组大小为什么是4*maxn
以下方建树代码为例,r数组表述原始数据,t表述tree也就是树状数组 void make(int left,int right,int num)//创建线段树 { t[num].l=left; t[n ...
- pl/sql developer试用期结束
(产品代码)Product Code:ljkfuhjpccxt8xq2re37n97595ldmv9kch (序列号)Serial Number:302967 (口令)Password:xs374ca ...
- Exception in thread "http-apr-8080-exec-1" java.lang.StackOverflowError
Exception in thread "http-apr-8080-exec-1" java.lang.StackOverflowError 可能执行了递归,陷入了死循环 如下我 ...
- 杭电oj 2072————统计单词数(java)
problem:统计单词数 思路:利用HashMap的特性——不能反复存储同一个键得数据,所以可以保证map里边儿的元素都是不重复的,存储完毕之后直接输出size就好了 注意事项: 1.利用strin ...
- 小匠第二周期打卡笔记-Task04
一.机器翻译及相关技术 机器翻译(MT):将一段文本从一种语言自动翻译为另一种语言,用神经网络解决这个问题通常称为神经网络翻译(NMT). 主要特征:输出是单词序列而不是单个单词.输出序列的长度可能与 ...
- oracle数据库操作 接口封装
1.如下 using Oracle.ManagedDataAccess.Client; using System; using System.Collections.Generic; using Sy ...