Spring boot热加载

1.项目依赖添加spring-dev-tools

2.application.yml添加

spring:
  devtools:
    remote:
      secret: thisismysecret

3.在 Intellij IDEA 当中的 Preference -> Build, Execution, Deployment -> Compiler 中勾选 Build project automatically

4.在 IDEA 的 registry 中勾选 compiler.automake.allow.when.app.running (macOS 下使用 option + command + shift + / ,Windows 下使用 Ctrl + Alt + Shift + / 调出 registry 菜单)
然后寻找到 compiler.automake.allow.when.app.running,进行勾选

最后重启 IDE,在 Run/Debug Configurations 中新建一个 Spring Boot 模板的配置。其中 Main Class 填入 org.springframework.boot.devtools.RemoteSpringApplication (注意哦,点右边的省略号按钮勾选 include non-project classes 的选择才有效)。然后在 Program arguments 中填入服务地址,比如你的服务端口是 8080 就填 http://localhost:8080; Working Directory 填写 ,而 Use classpath of module 选择当前项目即可。

你可能感兴趣的:(Spring boot热加载)