SpringBoot实战(三)代码热部署

 每次代码改动后都需要重新手动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】

 

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

 

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

 

posted @ 2018-09-07 13:37  柳云居士  阅读(1433)  评论(4编辑  收藏  举报