IDEA项目热部署

  在开发Springboot项目的时候,经常做一个小改动就需要重启项目,然后再进行相应的测试,这样不仅体验差而且浪费时间,在这种情况下,可以使用热部署在项目修改之后自动进行重启。下面记录一下自己的使用过程:

创建项目

1.在创建项目的时候,引入devtools依赖
在这里插入图片描述

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      <optional>true</optional>
</dependency>

2.先写个controller进行简单测试

@Controller
@RequestMapping("/index")
public class testController {

	@ResponseBody
	@RequestMapping("/testIndex")
	public Object testIndex(){

		return "index123";
	}
}

3.此项目的端口我修改为8083,所以启动项目之后,访问此服务
在这里插入图片描述
 接口返回了index123,此时在项目中把"index123"改成"index1234",在刷新此页面,发现返回的依旧是index123。原因相信大家都知道怎么回事。下面对IDEA做些修改。

4.按如下步骤,勾选Build project automatically
在这里插入图片描述
5.然后点击快捷键Crtl+Shift+Alt+/,选择Reigstry
在这里插入图片描述
6.重启IDEA,当我们在项目中将index123修改为index111的时候,按下保存,项目将自动重启,就可以进行响应测试了。
在这里插入图片描述

原文地址:https://www.cnblogs.com/wgty/p/12810467.html