在pom.xml中新增如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
使用IntelliJ IDEA时,其不是自动编译的,因而要是热部署生效,需采取如下方式(二选一):
方式一:
手动编译,修改完代码按快捷键Ctrl+F9完成编译,编译单个文件Ctrl+Shift+F9
方式二:
自动编译。
Mac:IntelliJ IDEA -> Preferences -> Compiler,勾选Make project automatically
按快捷键Command+Option+Shift+/,选择Registry...,勾选上compiler.automake.allow.when.app.running