所谓热部署就是开发者修改代码后可以免除重启服务器的烦恼,在SpringBoot中我们使用的是Devtools。
实践操作
Maven:添加<optional>true</optional>,它可以防止devtools被传递到其他使用你的项目的模块中。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
其实在添加Maven后,基础功能都可以使用了,改动代码之只要Ctrl+F9(Idea),即可直接生效。但是作为程序员每次写完又要保存又要Ctrl+F9也是一件很麻烦的事儿,并且Ctrl+F9就键位上来说,按起来并不是非常方便,所以还有更加懒惰的方法。
勾选:File --> Settings --> Compiler --> Build Project automatically

勾选:ctrl + shift + alt + / --> Registry --> Compiler autoMake allow when app running


这样只要一保存,就会自动编译了,Devtools的一些基本使用方法就在这里了。
更多更详细的设置以及方法可以查看:https://www.jianshu.com/p/99f17c7e12f5
网友评论