一、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每次都会重置的