【SpringBoot】项目实现热部署的两种方式

前言

  • spring boot : 2.0.0.RELEASE
  • maven
  • eclipse
  • 另外还需清楚什么是热部署,以及为什么要热部署。
  • SpringBoot项目中实现热部署的两种方式,使得部署变得异常简单,同时两种方式也非常的简单。

实操

devtools

Pom.xml中直接添加依赖即可:

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>

springloaded

Pom.xml中直接在spring-boot插件中添加依赖即可:

<plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <dependencies>
            <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>springloaded</artifactId>
              <version>1.2.6.RELEASE</version>
            </dependency>
          </dependencies>
          <configuration>
            <mainClass>此处为入口类</mainClass>
          </configuration>
        </plugin>

借鉴的说明

真正实现热部署的只是后者,前者只是实现了热启动。从控制台日志就可以看出来。

猜你喜欢

转载自blog.csdn.net/sayyy/article/details/80844051