1. 程式人生 > 實用技巧 >SpringBoot2.X Devtools 熱部署

SpringBoot2.X Devtools 熱部署

pom檔案引入所需jar包

springboot版本採用2.3.1

 <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-devtools</artifactId>
          <configuration>
            <fork>true</fork>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

啟動設定成熱部署

修改程式碼後點擊重新整理即可

控制檯重新列印SpringBoot圖示就可以了