SpringBoot实战(三)代码热部署

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

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

<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】勾选spring-boot

 

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

相关文章
相关标签/搜索