SpringBoot系列之IDEA项目中设置热部署教程

1、新建SpringBoot项目

环境准备

  • JDK 1.8
  • SpringBoot2.2.1
  • Maven 3.2+
  • 开发工具
    • smartGit
    • IntelliJ IDEA2018

创建一个SpringBoot Initialize项目,详情可以参考我之前博客:SpringBoot系列之快速创建项目教程

在这里插入图片描述

检查spring-boot-devtools是否加上?

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>

ps:修改如下配置,reload才生效,<fork>true</fork>,用于明确表示编译版本配置有效

在这里插入图片描述

补充:
如果有加上Thymeleaf模板引擎,需要关了Thymeleaf缓存,然后按Ctrl+F9重新编译,修改配置文件:

spring:
  thymeleaf:
    cache: false

2、IntelliJ IDEA配置

Settings->Build,Execut, Deployment -> Compiler,勾选中左侧的Build Project automatically


在这里插入图片描述

Ctrl+Alt+Shift+/,选择Registry

在这里插入图片描述

勾选complier.automake.allow.when.app.running


在这里插入图片描述

ok,next需要重启 IntelliJ IDEA,既可实现java文件自动构建,不过对于html还是要按Ctrl+F9编译

代码例子下载:code download

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容