接上一篇:https://blog.youkuaiyun.com/sinat_22808389/article/details/81590042
在开发过程中,每次修改代码都要重新启动服务?好费时间啊,来看看怎么样让springBoot实现热加载,即不用重启服务,修改的代码即时生效。
很简单,引入依赖如下,便可:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
我们第一次访问:http://localhost:8080/hello 结果如下:
不关闭服务,我们去改RestController类:
public class RestController {
@RequestMapping("/hello")
public String helloSprinBoot() {
return "hahaha";
}
}
然后再去访问 http://localhost:8080/hello,结果如下:
在没有重启服务的情况下,修改的代码生效了!至此热加载配置就完成了!