SpringBoot热部署教程
热部署
是指当项目资源或程序发生变化时,不需要开发人员手动重启服务器即可实现功能的更新。掌握了这一强大"黑科技"后,哪里不对改哪里,改了即刻见效,妈妈再也不用担心我的调错效率~五步教你用后真香
1 勾选热部署项
File–>Settings–>Build,Execution,Development–>Compiler
勾选Build project automatically
选项
2 Registry配置
Ctrl+Shift+Alt+/,选择第一项
Registry
在
Registry
界面找到相应的key并将value勾选
Key:compiler.automake.allow.when.app.running
Value:√
3 添加Springboot DevTools依赖
到 Maven Repository 中搜索Springboot DevTools依赖,并在项目的
pom.xml
文件中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>2.7.2</version>
</dependency>
4 配置maven
下拉
pom.xml
文件,在<plugin></plugin>
标签中配置Maven,添加
<fork>true</fork>
5 配置SpringBoot的更新策略
选择当前SpringBoot启动类对应的
Edit Configurations...
将
On 'Update' action
改为Update classes and resources
后点击Apply
完成上述操作后即可实现高效快捷的热部署开发,不妨动手尝试一下吧!