SpringBoot2.X Devtools热部署实现解析

时间:2022-01-26 05:18:42

pom文件引入所需jar包

springboot版本采用2.3.1

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  <maven.compiler.source>1.7</maven.compiler.source>
  <maven.compiler.target>1.7</maven.compiler.target>
  <springboot.version>2.3.1.RELEASE</springboot.version>
 </properties>
 <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter</artifactId>
   <version>${springboot.version}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-devtools</artifactId>
   <version>${springboot.version}</version>
  </dependency>
  <dependency>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
   <version>${springboot.version}</version>
  </dependency>
<!--插件里面加入热部署插件-->
<build>
  <finalName>spring-boot-devtools</finalName>
  <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
   <plugins>
    <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${springboot.version}</version>
          <configuration>
            <fork>true</fork>
          </configuration>
        </plugin>
   </plugins>
  </pluginManagement>
 </build>

启动设置成热部署

SpringBoot2.X Devtools热部署实现解析

修改代码后点击刷新即可

控制台重新打印SpringBoot图标就可以了

SpringBoot2.X Devtools热部署实现解析

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://www.cnblogs.com/xiaohaojs/p/13512913.html