不少網上的例子不夠準確,只須要完成下面幾步便可:spring
1.加入這兩個依賴app
<dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.6.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional><!-- 這個須要爲 true 熱部署纔有效 --> <version>1.3.0.RELEASE</version> </dependency>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <!-- 沒有該配置,devtools 不生效 --> <fork>true</fork> </configuration> </plugin> </plugins> </build>
2.file>setting>build....>compiler 勾上build project automaticallymaven
3.按快捷鍵 ctrl+shirt+alt+/spring-boot
在彈出的界面選擇registryui
找到 complier.automake.allow.when.app.running 勾上部署
4.重啓IDEA 啓動,更改文件後的2到3S會reloadio