一、pom.xml文件導入所需依賴文件,在dependencys結點中添加:
<!--添加熱部署--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> <scope>true</scope> </dependency>
二、pom.xml文件build標簽進行修改如下
<plugin> <!--熱部署配置--> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!--fork:如果沒有該項配置,整個devtools不會起作用--> <fork>true</fork> </configuration> </plugin>
三、設置IDEA的自動編譯:
點擊菜單File-Settings-Compiler勾選 Build Project automatically
四、按快捷鍵 ctrl + shift + alt + /,選擇Registry,勾上 Compiler autoMake allow when app running
五。重啟IDEA即可生效