一 Idea
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
修改代码以后,直接按Ctrl+F9(Build+Project)就会重新启动加载
二 Eclipse
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
修改代码以后,直接按Ctrl+S就会重新启动加载
不被热部署的文件:
1、/META-INF/maven, /META-INF/resources, /resources, /static, /public, or /templates2、指定文件不进行热部署spring.devtools.restart.exclude=static/,public/3、手工触发重启spring.devtools.restart.trigger-file=trigger.txt改代码不重启(推荐)不然Crtl+S保存一次,就重启一次,很麻烦,指定触发文件,可以统一加载。
通过一个文本去控制 https://docs.spring.io/spring-boot/docs/2.1.0.BUILD-SNAPSHOT/reference/htmlsingle/ 注意点:生产环境不要开启这个功能,如果用java -jar启动,springBoot是不会进行热部署的