使用Idea 开发SpringBoot项目, 修改完代码以后,要重新启动 Application 才可以看到效果。这样做开发效率肯定是大受影响的。可以通过热部署、热更新来实时加载更改,提高效率。
1、引入热部署插件
<!--热部署插件-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!--这个设置为true热部署才会生效-->
</dependency>
2、IDEA热更新配置
Idea需要进行两处的配置。
2.1 项目自动编译
File
Settings
Build,Excution,Deployment
Compiler
Build project automatically
2.2 开启automake 选项
Ctrl+Shift+A ->搜索registry,找到Registry...,(注意是后面有三个点),然后找到compiler.automake.allow.when.app.running,勾选即可:
新版IDEA,没有2.2这一步