一、pom.xml文件增長java
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
二、在pom.xml裏增長插件spring
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <!-- 若是沒有該配置,devtools不會生效 --> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
三、修改idea裏的選項緩存
打開idea ,File->Settings-> Build-Execution-Deployment -> Compiler,勾選 Build Project Automatically. session
四、mac按shift+command+/ app
將看到彈窗 Enter Action or option name,輸入"registry",雙擊第一項"Registry..." ,會彈出另外一個窗口,尋找< compiler.automake.allow.when.app.running> 選中,參考如圖:maven
五、項目 Update選擇Update Classes and resourceide
六、熱部署注意事項spring-boot
(1)若是使用模板引擎,關閉緩存ui
在application.properties中添加idea
#禁止thymeleaf緩存(建議:開發環境設置爲false,生成環境設置爲true)
spring.thymeleaf.cache=false
(2)開啓熱部署後,session每次都會重置的