springboot热部署
Spring Boot 热部署指在应用运行过程中修改项目代码、配置文件或静态资源后,无需手动重启应用即可自动生效,仅对修改的项目代码快速重启。
Spring Boot 内置的 spring-boot-devtools 开发工具模块专门为开发者提供热部署支持,能够实现避免全量加载依赖,大幅缩短重复重启的等待时间,显著提升开发迭代效率。
引入依赖
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional></dependency>代码如下
packagecom.qcby.springboot;importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublicclassHelloWorldSpringBootMain{publicstaticvoidmain(String[]args){SpringApplication.run(HelloWorldSpringBootMain.class,args);}}packagecom.qcby.springboot.controller;importorg.springframework.stereotype.Controller;importorg.springframework.web.bind.annotation.RequestMapping;importorg.springframework.web.bind.annotation.ResponseBody;@ControllerpublicclassHelloController{@ResponseBody@RequestMapping("/hello")publicStringhello(){return"Hello World!";}}启动后的效果如下
修改java代码或者配置文件模板后可以通过 ctrl+f9 来实施热部署