spring-boot 使用thymleaf修改页面不重启生效

开发环境用如下配置即可

spring.mvc.static-path-pattern=/static/**

# 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.web.resources.static-locations是后续配置,旧版Springboot的配置项为:spring-resources-static-locations;在2.2.5版本之后,旧版本配置已经失效。

spring.resources.cache-period=0

其他环境或打包运行:

spring.thymeleaf.prefix=classpath:/templates/
spring.web.resources.static-locations=classpath:/static/

完整thymleaf配置:

<properties>  
    <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
    <thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version>
</properties>

server.servlet.multipart.enabled=true
server.servlet.multipart.max-file-size=50MB
server.servlet.multipart.max-request-size=100MB


server.mvc.servlet.path=/
spring.mvc.static-path-pattern=/static/**


spring.thymeleaf.cache=true
spring.thymeleaf.check-template=true
spring.thymeleaf.check-template-location=true
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.suffix=.html


spring.web.resources.static-locations=classpath:/static/
  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值