侧边栏壁纸
博主头像
浅醉谷博主等级

行动起来,活在当下

  • 累计撰写 6 篇文章
  • 累计创建 10 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

IDEA+SpringBoot+Thymeleaf热部署

浅醉
2024-05-29 / 0 评论 / 0 点赞 / 44 阅读 / 1919 字 / 正在检测是否收录...

添加依赖

 <!--让顶目支持热更新-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional><!--这个需要为 true热部署才有效-->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId >spring-boot-starter-web </artifactId>
        </dependency>
        <!-- spring-boot-starter-thymeleaf -->
        <dependency >
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf </artifactId>
        </dependency>

关闭Thymeleaf缓存

application.properties配置文件中添加:

spring.thymeleaf.cache=false

IDEA配置修改

打开自动编译:

配置1:

配置2:

注:如果低版本IDEA可能找不到配置2,可以快捷键Ctrl+Shift+Alt+/

验证

重新启动项目看到如下restaredMain即设置成功:(修改代码后刷新页面会获取到最新状态,可能有几秒延迟)

0

评论区