在没有加入热部署前,我们增加文件和修改类方法的时候,都需要重启才能生效,有了热部署,我们就节省了一些不必要繁琐的重启操纵。
首先先从启动器启动服务器
在pom.xml加入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
在前面的基础上,如果你没有配置支持jsp之前默认访问是这样子的
![](https://i-blog.csdnimg.cn/blog_migrate/8fafaa3cc109c896a1a82035cb6b480e.png)
首页默认访问的是index.html页面,在加入热部署devtools之后我们在templates给他加一个index.html,在不重启的情况下刷新访问
![](https://i-blog.csdnimg.cn/blog_migrate/98c5ce5c7af62ed64b6b98db2e3f8f32.png)
修改Usercontroller类增加test2路径和方法跳转指向index.html
![](https://i-blog.csdnimg.cn/blog_migrate/f0e92fd61af6e8f029dc4c34d7b5eb98.png)
![](https://i-blog.csdnimg.cn/blog_migrate/cb8e5ee4a457c193b8bd5b440663d82d.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e9bf9814a21a38318fd3a5b40db89113.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5df9db06f46ae12b1370c1450b932de8.png)
修改完控制台刷新后就可以直接访问默认页了