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

1、新建SpringBoot项目

环境准备

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

创建一个SpringBoot Initialize项目,详情可以参考我之前博客:SpringBoot系列之快速创建项目教程
SpringBoot系列之IDEA项目中设置热部署教程_第1张图片
检查spring-boot-devtools是否加上?


            org.springframework.boot
            spring-boot-devtools
            runtime
            true
        

ps:修改如下配置,reload才生效,true,用于明确表示编译版本配置有效
SpringBoot系列之IDEA项目中设置热部署教程_第2张图片
补充:
如果有加上Thymeleaf模板引擎,需要关了Thymeleaf缓存,然后按Ctrl+F9重新编译,修改配置文件:

spring:
  thymeleaf:
    cache: false

2、IntelliJ IDEA配置

Settings->Build,Execut, Deployment -> Compiler,勾选中左侧的Build Project automatically
SpringBoot系列之IDEA项目中设置热部署教程_第3张图片

Ctrl+Alt+Shift+/,选择Registry

SpringBoot系列之IDEA项目中设置热部署教程_第4张图片
勾选complier.automake.allow.when.app.running
SpringBoot系列之IDEA项目中设置热部署教程_第5张图片

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

代码例子下载:code download

你可能感兴趣的:(SpringBoot系列之IDEA项目中设置热部署教程)