SpringBoot学习:使用spring-boot-devtools进行热部署

项目下载地址:http://download.csdn.net/detail/aqsunkai/9805821

pom.xml添加依赖:

SpringBoot学习:使用spring-boot-devtools进行热部署
<!--支持热启动jar包-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot.version}</version>
<optional>true</optional>
<!-- optional=true,依赖不会传递,该项目依赖devtools;之后依赖该项目的项目如果想要使用devtools,需要重新引入 -->
</dependency>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
<dependencies>
<!-- spring热部署-->
<!-- https://mvnrepository.com/artifact/org.springframework/springloaded -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.6.RELEASE</version>
</dependency>
</dependencies>
</plugin>
SpringBoot学习:使用spring-boot-devtools进行热部署

application.yml配置文件中添加:

SpringBoot学习:使用spring-boot-devtools进行热部署
spring:
devtools:
restart:
#热部署生效
enabled: true
#设置重启的目录
#additional-paths: src/main/java
#classpath目录下的WEB-INF文件夹内容修改不重启
exclude: WEB-INF/**
SpringBoot学习:使用spring-boot-devtools进行热部署

设置WEB-INF下的jsp修改不需要重启。

当我们修改了java类后,IDEA默认是不自动编译的,而spring-boot-devtools又是监测classpath下的文件发生变化才会重启应用,所以需要设置IDEA的自动编译:

(1)CTRL + SHIFT + A --> make project automatically --> make project automatically

(2)File-Settings-Compiler-Build Project automatically

SpringBoot学习:使用spring-boot-devtools进行热部署

(3)ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running
SpringBoot学习:使用spring-boot-devtools进行热部署

转载地址:https://www.cnblogs.com/aqsunkai/p/6690574.html

上一篇:更多细节的理解RSA算法


下一篇:http接口测试(python)