Springboot实现热启动、热部署

热启动:修改代码保存时会自动重新启动项目。

热部署:动态替换你修改的class,效率会更高。

1:最简单的就是对于idea使用ctrl+F9的方式可以实现热部署:但是需要修改完不断的按键,比较繁琐。

2:热启动

SpringBoot的web项目,在每一次修改了java文件或者是resource的时候,都必须去重启一下项目,这样的话浪费了很多的时间,实现了热启动,在每一次作了修改之后,都会自动的重启 第一步:引入热加载的插件,springboot 1.3开始就有的

org.springframework.boot

spring-boot-devtools

true

org.springframework.boot

spring-boot-devtools

true

project 中添加spring-boot-maven-plugin,主要在eclipse中起作用,idea不需要加此配置,springboot 项目的话,应该是有此配置,加里面的内容即可。

org.springframework.boot

spring-boot-maven-plugin

true

org.springframework.boot

spring-boot-maven-plugin

true

第二部 : idea设置(14版本) 1、点击: file ,Settings ,Build ,Execution,Deplment 然后记得apply,ok。 2、组合键:Shift+ALT+Ctrl+/ ,选择“Registry”,回车,找到“complier.automake.allow.when.app.running” 注意:

因为我的idea是14版本,有的15版本或者是更高的在compiler 里面是这样的: ,然后快捷键是Ctrl + Shift +A ,一样找到complier.automake.allow.when.app.running,点击勾选即可。

最后在application.yml中添加以下配置

spring:

devtools:

restart:

# 设置热部署生效

enabled: true

# 设置重启的目录

additional-paths: src/main/java

# WEB-INF目录下内容发生更改不重启

exclude: WEB-INF/*

第三部: 如果你用的浏览器和我的一样,那么就禁用缓存 按F12(更多工具—->开发者工具),找到network,勾选Disable Cache。

亲测有效。 另外,如果是eclipse的话,直接在pom.xml文件当中添加:

org.springframework.boot

spring-boot-devtools

true

org.springframework.boot

spring-boot-devtools

true

本文转载自:https://blog.csdn.net/boywcx/article/details/81164411


孙姓取名(精选名字102个)
有内涵的骂人句子(通用50句)