1. 設置“File” 》 Settings 》 Build,Execution,Deplyment 》Compiler,勾選 Build project automatically
2. 使用組合鍵:“Shift+Ctrl+Alt+/” ,選擇 “Registry” ,找到key “compiler.automake.allow.when.app.running” 並勾選(如果是通過mvn clean spring-boot:run 命令啓動項目的話是不用設置這個的,但是如果是通過主類main方法啓動的話是必須要設置)
3. pom.xml加上依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>