添加依赖
<!--热重启依赖-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>
application.yml配置
additional-paths对于多模块也有效,多模块下只要是此目录下的就会重新加载
spring:
  devtools:
    restart:
      enabled: true
      additional-paths: /src/main/java
idea设置
第一步
Preferences->Build,Execution,Deployment->Compiler找到 Build Project Automatically打勾选中
第二步
mac同时按住command+shift+alt+/,调出Maintenance(维护)控制台,选择Registry(登记)
勾选运行时自动编译(compiler.automake.allow.when.app.running)