手抄报 安全手抄报 手抄报内容 手抄报图片 英语手抄报 清明节手抄报 节约用水手抄报

SpringBoot42-热部署

时间:2024-10-13 06:24:35

1、下图是小编实验项目项目目录,如下图:

SpringBoot42-热部署

2、下图是小编springboot项目中的pom文件中的依赖,可以看到这里只是依赖了web和thymeleaf,如下图:

SpringBoot42-热部署

3、然后下图中是一个hello的controller,如下图:

SpringBoot42-热部署

4、下图是一个hello的html,访问hello的controller就会访问到这个html,如下图:

SpringBoot42-热部署

5、然后在target目录下的classes目录下会有编译之后的文件,这里可以看到mapping就是hello,如下图:

SpringBoot42-热部署

6、启动springboot项目,然后打开浏览器,然后访问hello,访问到了hello的html文件,如下图:

SpringBoot42-热部署

7、此时我们修改hello的controller的mapping为helloaaa,如下图:

SpringBoot42-热部署

8、按【Ctrl+F9】即可编译到target下的classes目录下,这里编译之后也是helloaaa,如下图:

SpringBoot42-热部署

9、浏览器访问helloaaa,访问失败,因为即使已经【Ctrl+F9】编译了修改之后的contro盟敢势袂ller,但是并没有部署到服务器中,如下图:

SpringBoot42-热部署

10、然后在pom文件中添加spring的热部署依赖,如下图:

SpringBoot42-热部署

11、重启springboot项目,访问helloaaa,如下图:

SpringBoot42-热部署

12、然后修改controller的mapping为hellobbb,然后看控制台热部署很快的部署启动了服务器,如下图:

SpringBoot42-热部署

13、然后直接访问hellobbb,可以看到不需要重新启动springboot项目也可以热部署修改,如下图:

SpringBoot42-热部署
© 手抄报圈