声明使用 idea 2018.2版本,springboot2.0、完成springboot的热更新部署
完成springboot 热部署,但是也存在热部署失效的情况;下面讲;
maven工程pom.xml中引入热部署的依赖,以及maven支持的fork;
1、引依赖
<!-- springboot 进行热部署依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-Devtools</artifactId>
<optional>true</optional>
</dependency>
fork
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<!-- 配置 fork 进行热部署支持 -->
<configuration>
<fork>true</fork>
</configuration>
</plugin>
2、settings中 compiler勾选 build project automatically
使用组合键 :ctrl shift alt / 选择 Registry,勾选 compile.automake.allow.when.app.running 复选框;
或者使用使用快捷键 Ctrl + Shift + A,在输入框中输入 Registry,点击如图所示,勾选compile.automake.allow.when.app.running 复选框;
3、热部署失效情况:
该模块在完整的打包环境下运行的时候会被禁用,如果你使用 java-jar 启动应用或者用一个特定的 classloader 启动,它会认为这是一个“生产环境”。*