【IDEA】 SpringBoot如何实现热加载

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/pengyangyan/article/details/88812256

1.pom.xml中引入依赖

      <!--热部署 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency>

2.配置application.yml文件或者application.properties文件

spring:
  mvc:
    view:
      prefix: /pages/
      suffix: .html  
  devtools:
    restart:
      enabled: true
      additional-paths: src/main/java  
      exclude: /webapp   #页面所载目录

3.设置IDEA支持热加载

File --> Setting --> Build,Execution,Deployment --> Compiler -->  勾选 Build project antomatically

4.重新运行项目,然后修改文件,Ctrl + S 就能看到项目自动重启,而且重启时间远小于第一次启动时间,因为springboot只重启被修改的部分。

猜你喜欢

转载自blog.csdn.net/pengyangyan/article/details/88812256