设置spring boot 热重启之后,idea会自动监听代码的改动,发现改动之后会自动编译,无需手动重启就能看到修改之后的运行效果。
一:在maven里添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope><!-- -->
<optional>true</optional>
</dependency>
二:在settings(ctrl +alt+s) -> Build,Execution,Deployment -> compiler, 添加"Build project automatically"
三:使用快捷键ctrl+shift+a,然后输入registry,然后点击进入,勾选compiler.automake.allow.when.app.running
四:重启IntellijIDEA。
Note:不过经过我测试,一般修改代码一分钟左右才会自动编译,反应比较慢…