每次修改代码都要重启服务器,这是很痛苦的事,所以我们来看看如何热部署。
1,pom.xml加上
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
2,IDEA 设置
File-settings,勾上自动编译
Register配置:
Ctrl+Shift+Alt+/ => Register => 找到并勾选compiler.automake.allow.when.app.running => IDEA重启
确认IDEA重启后,debug启动SpringBoot项目 ,修改下IndexController中的字符为Hello word22223233
.
@RestController
public class IndexController {
@GetMapping("/index")
public ResponseEntity helloWord() {
return ResponseEntity.ok("hello word22223233");
}
}
测试成功!