记录一个SpringBoot 设置热部署(修改项目之后,项目自动重启)实例
POM.XML 文件
<!-- 配置springBoot项目的热部署启动 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
SpringBoot启动类的代码:
package com.xiaowu; import java.io.IOException; import org.apache.commons.httpclient.HttpException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * 这是一个配置了热部署启动的springBoot项目 * * * @author WQ * */ @RestController @SpringBootApplication public class Chapter1Application { @RequestMapping("/index") public String index() throws HttpException, IOException { return "Hello Spring Boot,我是WQ!!!!!"; } public static void main(String[] args) { SpringApplication.run(Chapter1Application.class, args); } }
修改返回值之后,点击保存,项目自动重启。
截图如下: