IntelliJ maven spring boot热加载
2020-04-26 本文已影响0人
zydmayday
https://docs.spring.io/spring-boot/docs/1.3.1.RELEASE/reference/html/howto-hotswapping.html
首先我尝试了官网(上述)的方法,但是发现好像并不太好用,于是我搜索了Stack Overflow的答案,
https://stackoverflow.com/questions/23155244/spring-boot-hotswap-with-intellij-ide
这个是可以用的。
第一步
在你的pom.xml中,
<dependencies>
<!-- 一些其他的依赖 -->、
<!-- 加入下述的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
第二步
Ctrl + Alt + S启动Settings窗口,

将图片所示的内容打钩,这样可以保证你在每次修改了代码之后IntelliJ都会帮你重新编译代码。
第三步
Ctrl + Shift + A启动下述界面,输入registry

选择Registry之后,在下述的窗口中找到compiler.automake.allow.when.app.running
并勾选。

在Registry dialog中,直接输入
running
,IntelliJ会自动帮你搜索,这样就不用一行一行的搜了。也算是IntelliJ中的一个小技巧。
debug启动你的应用即可享受热加载。