Mac上InteIIij IDEA使用springboot热部署

spring boot devtools

Posted by alovn on April 4, 2019

spring-boot-devtools

spring-boot-devtools 是一个为开发者服务的一个模块,其中最重要的功能就是在我们改变了一些代码或者配置文件的时候,应用可以自动重启,这在我们开发的时候,非常有用。 要包含devtools支持,需要将spring-boot-devtools模块依赖添加到项目构建中。

添加依赖

1
2
3
4
5
6
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <version>2.1.4.RELEASE</version>
    <optional>true</optional>
</dependency>

修改IDEA配置

实际开发中不可能每次改动后都手动Build,因此需要设置Idea的自动编译。

1
2
3
4
5
Preferences -> Build,Execution,Deployment - > Compiler -> Build project automatically 打勾

修改Registry
mac上快捷键:Command + Shift + A 选择 Registry
勾选自动编译选项 compiler.automake.allow.when.app.running 

重启启动应用服务后,对代码进行编辑,然后保存代码,将会触发自动编译过程。

devtools 本身就是开发时用的, 部署的时候,要关闭: 删掉devtools的maven依赖。