注意如下的熱部署方式在IDEA是默認沒有打開自動編譯的,手動編譯須要快捷鍵(Ctrl+Shift+F9),自動編譯的修改配置以下:(注意刷新不要太快,會有1-2秒延遲)html
在pom中直接引入依賴spring
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
設置如下兩項(第一項如已設置直接設置第二項)app
1) 「File」 -> 「Settings」 -> 「Build,Execution,Deplyment」 -> 「Compiler」,選中打勾 「Build project automatically」 。maven
2) 組合鍵:「Shift+Ctrl+Alt+/」 ,選擇 「Registry」 ,選中打勾 「compiler.automake.allow.when.app.running」 。spring-boot
以後直接正常run便可!ui
在Plugins中添加依賴spa
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <dependencies> <!-- spring熱部署 --> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.6.RELEASE</version> </dependency> </dependencies> </plugin> </plugins> </build>
// 若是依賴提示not found,先在上面寫讓maven下載下來,再移到Plugin裏面來命令行
命令行窗口啓動code
找到pom.xml的路徑,IDEA的話打開Pom後在標籤頁鼠標懸停便可看到,或者在pom上右擊->file Pathxml
在這個路徑下打開cmd窗口(win下能夠經過shift快速在對應路徑打開),輸入啓動命令
mvn spring-boot:run
轉載:https://www.cnblogs.com/jiangbei/p/8439394.html