每次代码改动后都需要重新手动Run项目,心累,在网上找了下,发现SpringBoot提供了热部署的方案,改动代码后自动编译打包,现在将热部署的配置方法记下来:

第一步:在pom.xml中添加依赖,导入spring-boot-devtools

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <scope>runtime</scope>
</dependency>

 

第二步:在Intellij编辑器中选择File->Setting->Build,Execution,Deployment->Compiler,勾选【Build project automatically】

SpringBoot实战(三)代码热部署

 

第三步:通过快捷键Ctrl+Alt+Shift+/  ,进入Intellij的Registry配置中,将【compiler.automake.allow.when.app.running】勾选

SpringBoot实战(三)代码热部署

 

到这里就大功告成,测试了一下,修改了代码以后,等待两秒钟,SpringBoot会重新编译加载代码,免去手动编译的烦恼。

 

相关文章:

  • 2021-09-13
  • 2021-10-24
  • 2021-11-28
  • 2021-06-11
  • 2021-08-15
  • 2021-04-02
  • 2022-01-23
猜你喜欢
  • 2021-12-13
  • 2021-08-21
  • 2022-01-12
  • 2022-12-23
  • 2022-02-04
  • 2021-12-12
相关资源
相似解决方案