不少网上的例子不够准确,只须要完成下面几步便可: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